📄 删除文件中的半个汉字作业.txt
字号:
; 删掉文件中的半个汉字---30060505钱学海
stack segment para stack
dw 100h dup(?)
stack ends
data segment para
filename1 db 'test.dat',0
handle1 dw ?
filename2 db 'test1.dat',0
handle2 dw ?
buff db 1024*10 dup(?)
len dw ?
data ends
code segment
assume cs:code,ds:data,ss:stack
start: mov ax,data
mov ds,ax
lea dx,filename1
mov cx,0
mov ah,3dh
mov al,0
int 21h
jnc l1
jmp return
l1: mov handle1,ax ;打开第一个文件
mov bx,ax
mov ah,3fh
mov cx,1025*10
lea dx,buff
int 21h
mov len,ax ;读取数据至缓冲区
lea si,buff ;查到半个汉字后,删除,并前移
mov di,si
push ds
pop es
cld
mov cx,len
lp1: test byte ptr[si],80h
jz con2
test byte ptr[si+1],80h
jnz con1
push si
push di
push cx
dec cx
inc si
cld
rep movsb
dec len
pop cx
dec cx
pop si
pop di
jmp lp1
con1: movsb
dec cx
con2: movsb
loop lp1
lea dx,filename2 ;创建第2个文件
mov cx,0
mov ah,3ch
int 21h
jc return
mov handle2,ax
mov bx,ax
mov ah,40h
mov cx,len
lea dx,buff
int 21h ;写入
mov bx,handle1
mov ah,3eh
int 21h
mov bx,handle2
mov ah,3eh
int 21h
return: mov ah,4ch
int 21h
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -