1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
code segment
assume cs:code
assume ds:data
assume ss:pile
debut:
mov ax,data
mov ds,ax
xor ax,ax
mov es,ax
push ax
; ouverture d'un fichier
xor cx,cx
mov dx,offset namefile
mov ah,3ch
int 21h
; preparation écriture
mov bx,ax
mov dx,offset carac
mov di,offset carac
xor cx,cx
boucle:
mov ah,40h
mov si,cx
mov al,es:[si] ; lecture dans la mémoire
mov ds:[di],al
push cx
mov cx,0001h
int 21h
pop cx
inc cx
cmp cx,0FFFFh
jne boucle
mov ah,40h
mov si,cx
mov cx,01h
mov al,es:[si]
mov ds:[di],al
int 21h
pop ax
cmp ax,0F000h
je fermeture
mov cx,1000h
add ax,cx
push ax
mov es,ax ; on passe au segment suivant
mov dx,offset carac
mov di,offset carac
xor cx,cx
jmp boucle
fermeture:
; fermeture du fichier
mov ah,3Eh
int 21h
attente_sortie:
xor ah,ah
int 16h ; attente d'une touche
sortie:
mov ah,4Ch
int 21h ; sortie du prog
code ends
data segment
namefile db "test.txt",0
carac db " "
data ends
pile segment stack
remplissage db 256 DUP (?)
pile ends
end debut |
Partager