.model small
.data
sname db 20 dup(0),00,'$'
dname db 20 dup(0),00,'$'
handle1 dw ?
handle2 dw ?
buff db ?
.data
sname db 20 dup(0),00,'$'
dname db 20 dup(0),00,'$'
handle1 dw ?
handle2 dw ?
buff db ?
.code
main proc
mov ax,@data
mov ds,ax
mov ah,62h ;address of psp
int 21h
mov es,bx ;save address in es
mov cl,es:[80h] ;length of tail
mov di,82h
lea si,sname ;1st character of tail;81h has space bar
dec cl ;for space bar
f1:
mov dl,es:[di]
cmp dl,20h ;20 for space
je space
mov [si],dl ;read sname
inc si
inc di
dec cl
jmp f1
space:
lea si,dname
inc di ;now di points to dname
dec cl
f2: mov dl,es:[di]
cmp cl,00h
je entr ;get fname2
mov [si],dl
inc di
inc si
dec cl
jmp f2
entr:
mov ah,3dh ;open 1st file
mov al,00h
lea dx,sname
int 21h
mov handle1,ax ;save handle
mov ah,3dh
mov al,01h ;write access
lea dx,dname
int 21h
mov handle2,ax
writ: mov ah,3fh
mov bx,handle1
mov cx,0001h ;read from f1 and write in buff
lea dx,buff
int 21h
cmp ax,00h
je ex
mov ah,40h
mov bx,handle2
mov cx,0001h
lea dx,buff
int 21h
jmp writ
ex:
mov ah,3eh
mov bx,handle1
int 21h
mov ah,3eh
mov bx,handle2
int 21h
mov ah,4ch
int 21h
main endp
end main
No comments:
Post a Comment