编写一个程序,新建一个文件:d:\abc.txt,从键盘输入文件的内容(不超过100个字 符)。然后新建一个文件:d:\def.txt,将d:\abc.txt文件的内容复制到d:\def.
data segment
buf db 100,?,100 dup(?)
file db 'abc.txt',0
fh dw ?
copyfile db 'def.txt',0
copyfh dw ?
copybuf db 100 dup(?)
error_msg db 0dh,0ah,'error!','$'
success_msg db 0dh,0ah,'done!','$'
data ends
stack segment stack
dw 20h dup(?)
top label word
stack ends
code segment
assume ds:data,cs:code,ss:stack
p proc far
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
lea sp,top
;create file
lea dx,file
mov cx,0
mov ah,3ch
int 21h
jc error
mov fh,ax
;buff
lea dx,buf
mov ah,0ah
int 21h
;get buff length in stack
xor ch,ch
mov cl,[buf+1]
;write file
lea dx,buf+2
mov bx,fh
mov ah,40h
int 21h
jc error
;create new file2
lea dx,copyfile
mov cx,0
mov ah,3ch
int 21h
jc error
mov copyfh,ax
;change point
xor cx,cx
xor dx,dx
mov bx,fh
mov al,0
mov ah,42h
int 21h
jc error
;read from file1
lea dx,copybuf
mov bx,fh
xor ch,0
mov cl,[buf+1]
mov ah,3fh
int 21h
jc error
;show the read content
xor ch,0
mov cl,[buf+1]
lea si,copybuf
l1: mov dl,[si]
inc si
mov ah,02h
int 21h
loop l1
;write to copyfile
lea dx,copybuf
mov bx,copyfh
mov ch,0
mov cl,[buf+1]
mov ah,40h
int 21h
jc error
jmp exit
error:
lea dx,error_msg
mov ah,09h
int 21h
exit:
mov ah,4ch
int 21h
p endp
code ends
end p
本文介绍了一个使用汇编语言实现的简单文件复制程序。该程序先创建一个名为abc.txt的文件并写入内容,然后将该文件的内容复制到另一个名为def.txt的新文件中。程序涉及文件操作的基本流程,包括文件的创建、读取、写入等关键步骤。
。然后新建一个文件:d:\def.txt,将d:\abc.txt文件的内容复制到d:\def.&spm=1001.2101.3001.5002&articleId=72870589&d=1&t=3&u=d47b0221f8e84c48beafee48af0be3c2)
3065

被折叠的 条评论
为什么被折叠?



