📄 tel1.asm
字号:
data segment
mess1 db '************************ tel ***************************',0ah,0dh,'$'
mess2 db '* this is main menu *',0ah,0dh,'$'
mess3 db '* insert (i) * ',0ah,0dh,'$'
mess4 db '* modify (m) * ',0ah,0dh,'$'
mess5 db '* delete (d) * ',0ah,0dh,'$'
mess6 db '* exit (e) *',0ah,0dh,'$'
mess7 db '********************************************************$'
mess8 db 'All info ',0ah,0dh,'$'
mess9 db '* list (l) *',0ah,0dh,'$'
mess10 db 'not found ',0ah,0dh,'$'
mess11 db ' please input:',0ah,0dh,'$'
mess12 db ' name :',0ah,0dh,'$'
mess13 db ' telnum :',0ah,0dh,'$'
mess14 db 0ah,0dh,'$'
fname db "d:\box.txt"
buffer1 db 23 dup(?)
buffer2 db 30 dup(?)
databuf db 512 dup(?)
handle dw ?
del db 8 dup('*')
data ends
show macro addrs
lea dx,addrs
mov ah,9
int 21h
endm
showc macro addrs1
push bx
mov bx,0
cou: mov dl,addrs1[bx]
mov ah,2
int 21h
inc bx
cmp bx,512
jl cou
pop bx
endm
set_p1 macro a
mov ah,2
mov dh,a
mov dl,40
mov bh,0
int 10h
endm
set_p3 macro
mov ah,2
mov dh,1
mov dl,46
mov bh,0
int 10h
endm
getin macro addrs,count2
local zeroit,lp,input,exit
push bx
push ax
mov bx,0
zeroit: mov addrs[bx],' '
inc bx
cmp bx,15
jl zeroit
mov bx,0
lp: mov ah,1
int 21h
cmp al,0ah
jz input
cmp al,0dh
jz input
mov addrs[bx],al
inc bx
cmp bx,count2
jl lp
input: cmp al,0dh
jz exit
cmp al,0ah
jz exit
mov ah,7
int 21h
jmp input
exit:
pop ax
pop bx
endm
code segment
main proc far
assume cs:code,ds:data,es:data
start:
mov ax,data
mov ds,ax
mov ah,0
mov al,3
int 10h
show mess1
show mess2
show mess3
show mess4
show mess5
show mess6
show mess9
show mess7
set_p3
w: mov ah,7
int 21h
cmp al,'i'
jnz n1
call insert
jmp w
n1: cmp al,'m'
jnz n2
call modify
jmp w
n2: cmp al,'d'
jnz n3
call delete
jmp w
n3: cmp al,'l'
jnz n4
call list
jmp w
n4: cmp al,'e'
jz exitf
jmp w
exitf:
set_p1 18
mov ah,4ch
int 21h
ret
main endp
insert proc near
push ax
push bx
push cx
push dx
set_p1 9
show mess14
show mess11
show mess12
show mess13
mov dx,offset fname ;open fie
mov al,2
mov ah,3dh
int 21h
mov bx,ax
set_p1 11
call get_rec
mov cx,0 ;move file pointer to end
mov dx,0
mov al,2
mov ah,42h
int 21h
mov cx,23 ;write file
mov dx,offset buffer1
mov ah,40h
int 21h
mov ah,3eh
int 21h
set_p3
pop dx
pop cx
pop bx
pop ax
call main
insert endp
get_rec proc near
push ax
push bx
getin buffer2,15
mov bx,0
mov cx,15
continue: mov al,buffer2[bx]
mov buffer1[bx],al
inc bx
loop continue
set_p1 12
getin buffer2,8
mov cx,8
continue1: mov al,buffer2[bx-15]
mov buffer1[bx],al
inc bx
loop continue1
pop bx
pop ax
ret
get_rec endp
list proc near
push ax
push bx
push cx
push dx
set_p1 15
show mess8
mov dx,offset fname
mov al,0
mov ah,3dh
int 21h
mov bx,ax
read:
mov cx,512
mov dx,offset databuf
mov ah,3fh
int 21h
showc databuf
set_p1 1
pop ax
pop bx
pop cx
pop dx
ret
list endp
delete proc near
push ax
push bx
push cx
push dx
set_p1 10
show mess14
show mess11
show mess12
set_p1 12
mov dx,offset fname
mov al,2
mov ah,3dh
int 21h
mov bx,ax
mov handle,ax
getin buffer1,15
read1:
mov dx,offset buffer2
mov cx,23
mov ah,3fh ;read file
int 21h
;jc exit3
lea si,buffer2
lea di,buffer1
mov cx,15
c1:
mov dl,byte ptr[si] ;cmp read,input
cmp dl,byte ptr[di]
jnz read1
inc si
inc di
loop c1
mov bx,handle
mov ah,42h
mov al,1
mov cx,0ffffh
mov dx,-8
int 21h
mov cx,8
mov dx,offset del
mov ah,40h
int 21h
mov ah,3eh
int 21h
jmp exit1
exit3:
set_p1 10
show mess10
exit1:
set_p3
pop dx
pop cx
pop bx
pop ax
ret
delete endp
modify proc near
push ax
push bx
push cx
push dx
set_p1 9
show mess14
show mess11
show mess12
show mess13
set_p1 11
mov dx,offset fname
mov al,2
mov ah,3dh
int 21h
mov bx,ax
mov handle,ax
getin buffer1,15 ; contact is in buffer1
read2:
mov dx,offset buffer2
mov cx,23
mov ah,3fh
int 21h
lea si,buffer2
lea di,buffer1
mov cx,15
c2:
mov dl,byte ptr[si]
cmp dl,byte ptr[di]
jnz read2
inc si
inc di
loop c2
mov bx,handle
mov ah,42h
mov al,1
mov cx,0ffffh
mov dx,-8
int 21h
mov cx,8
set_p1 12
getin buffer1,8
mov dx,offset buffer1
mov ah,40h
int 21h
mov ah,3eh
int 21h
jmp exit2
exit2:
set_p3
pop dx
pop cx
pop bx
pop ax
ret
modify endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -