📄 delet.asm
字号:
public delete
Psize equ 8
Rsize equ 49
dataseg segment
myfcb label byte
fcbdriv db 0
fcbname db 'students'
fcbext db 'txt'
fcbblk dw 0
fcbrcsz dw 0
dd ?
dw ?
dt ?
fcbwqrc db 0
dd ?
my_fcb label byte
fcb_driv db 0
fcb_name db 'students'
fcb_ext db 'txt'
fcb_blk dw 0
fcb_rcsz dw 0
dd ?
dw ?
dt ?
fcb_wqrc db 0
dd ?
dtapar label byte
maxl db 49
act db ?
dta db 49 dup(?)
dtap label byte
maxle db 49
actl db ?
mydta db 49 dup(?)
crlf db 13,10,'$'
num db 6 dup(?)
names db 10 dup(?)
sex db ?
birth db 8 dup(?)
place db 3 dup(?)
score1 db 5 dup(?)
score2 db 5 dup(?)
score3 db 5 dup(?)
total db 5 dup(?)
err_fopen db 0ah,0dh," File open error! $"
err_fcreat db 0ah,0dh," File creat error!$"
err_fread1 db 0ah,0dh," File read error in sequence manner! $"
err_fread2 db 0ah,0dh," File read error in random manner !$"
err_fclose db 0ah,0dh," File close error !$"
d_ms db 13,10,'Please input delet num :$'
del_sto db 40 dup(49 dup(?)),'$'
del_num db 6 dup(?),'$'
del_err db 13,10,'the file is end !$'
record_num1 db ?
record_num2 db ?
notar db 13,10,'this num is not in the queue!$'
del_creat db 'del_creat error!',13,10,'$'
erfwt db 'write error! ',13,10,'$'
del_suc db 'delete succesful!',13,10,'$'
dataseg ends
show macro addrs
;display a line started at addrs.
push dx
lea dx,addrs
mov ah,09h
int 21h
pop dx
endm
codeseg segment
assume cs:codeseg,ds:dataseg,es:dataseg
delete proc far
push ds
push es
mov ax,dataseg
mov es,ax
mov ds,ax
call delet
call closef
pop es
pop ds
ret
delete endp
openf proc near
mov ah,0fh
lea dx,myfcb
int 21h
or al,al
jz found
show err_fopen
found: mov fcbrcsz,49
mov ah,1ah
lea dx,dta
int 21h
ret
openf endp
closef proc near
mov ah,10h
lea dx,myfcb
int 21h
ret
closef endp
closef1 proc near
mov ah,10h
lea dx,my_fcb
int 21h
ret
closef1 endp
delet proc near
lea di,del_sto
call openf
or al,al
je del_be
jmp del_exit
del_be:
show d_ms
mov bx,0
del_in:
mov ah,1
int 21h
mov del_num[bx],al
inc bx
cmp bx,6
jl del_in
mov record_num1,0
mov record_num2,0
del_read:
lea dx,myfcb
mov ah,14h
int 21h
cmp al,01
jne del_m3
jmp del_fend
del_m3:
cmp al,0
je del_m4
cmp al,03
je del_fend
del_m4:
del_compar:
push di
lea di,dta
lea si,del_num
mov cx,6
cld
rep cmpsb
pop di
jz del_r
jmp del_writ
del_r:
inc record_num1
push di
push si
cld
lea di,dta
mov cx,24
mov ax,2020h
rep stosw
pop si
pop di
jmp del_read
del_writ:
inc record_num1
inc record_num2
lea si,dta
mov cx,49
cld
rep movsb
push di
push si
cld
lea di,dta
mov cx,24
mov ax,2020h
rep stosw
pop si
pop di
jmp del_read
del_fend:
call closef
mov al,record_num1
cmp al,record_num2
je no_tar
lea dx,my_fcb
mov ah,16h
int 21h
or al,al
jne del_exit
mov bx,0
dec record_num2
del_cre:
push di
push si
cld
lea di,mydta
mov cx,49
mov ax,2020h
rep stosb
pop si
pop di
lea si,del_sto[bx]
lea di,mydta
mov cx,49
cld
rep movsb
mov fcb_rcsz,49
mov ah,1ah
lea dx,mydta
int 21h
mov ah,15h
lea dx,my_fcb
int 21h
add bx,49
dec record_num2
jnz del_cre
call closef1
show crlf
show del_suc
jmp del_ret
no_tar: show notar
jmp del_ret
del_exit:
show del_creat
del_ret:
ret
delet endp
codeseg ends
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -