File compilato + sorgente qui: Mcopy.zip
;Questo programma ha le stesse funzioni del copy del DoS, ovvero copia un file
;in un altro.
.model small
.stack
.data
File1 db 50 DUP (0)
File2 db 50 DUP (0)
Handle1 dw ?
Handle2 dw ?
Buffer db 3000 DUP (?)
msg0 db "Sintassi di comando errata.", 13, 10, '$'
msg1 db "Impossibile trovare il file specificato.", 13, 10, '$'
msg2 db "File di destinazione esistente. Sovrascrivere? (s/n) $"
msg3 db "Errore durante la cancellazione del file $"
.code
acapo macro
mov ah, 2
mov dl, 0dh
int 21h
mov ah, 2
mov dl, 0ah
int 21h
endm
inizio:
mov ax, @data
mov ds, ax
mov dl, [es:80h]
cmp dl, 0
je errore
xor si, si
xor di, di
acquisizione_file_1: mov dl, [es:82h+si]
cmp dl, 20h
je acquisizione_file_2
mov File1[si], dl
inc si
jmp acquisizione_file_1
errore: lea dx, msg0
mov ah, 9
int 21h
jmp fine
acquisizione_file_2: inc si
mov dl, [es:82h+si]
cmp dl, 13
je avanti
mov File2[di], dl
inc di
jmp acquisizione_file_2
avanti: lea dx, File1
mov ah, 4eh
mov cx, 3fh
int 21h
jc non_esiste
lea dx, File2
mov ah, 4eh
mov cx, 3fh
int 21h
jnc sovrascrivi
crea: lea dx, File2
mov ah, 3ch
mov cx, 0
int 21h
lea dx, File1
mov ah, 3dh
mov al, 0
int 21h
mov Handle1, ax
lea dx, File2
mov ah, 3dh
mov al, 1
int 21h
mov Handle2, ax
lea dx, Buffer
mov ah, 3fh
mov bx, Handle1
mov cx, 3000
int 21h
push ax
lea dx, Buffer
mov ah, 40h
mov bx, Handle2
pop cx
int 21h
mov bx, Handle1
mov ah, 3eh
int 21h
mov bx, Handle2
mov ah, 3eh
int 21h
stop: acapo
jmp fine
cancella_file: lea dx, File2
mov ah, 41h
int 21h
jnc crea
lea dx, msg3
mov ah, 9
int 21h
jmp fine
non_esiste: lea dx, msg1
mov ah, 9
int 21h
jmp fine
sovrascrivi: lea dx, msg2
mov ah, 9
int 21h
mov ah, 1
int 21h
cmp al, 's'
je cancella_file
cmp al, 'S'
je cancella_file
cmp al, 'n'
je stop
cmp al, 'N'
je stop
acapo
jmp sovrascrivi
fine: mov ah, 4ch
int 21h
end inizio |