📄 69.asm
字号:
;6_9.asm
;*************************************************************************
.model small
.stack 100h
;*************************************************************************
.data
namepar label byte
maxname db 21
actname db ?
namefld db 21 dup(?)
phonepar label byte
maxphone db 9
actphone db ?
phonefld db 9 dup(?)
tel_tab db 50 dup(20 dup(?),8 dup(?))
namesav db 20 dup(?),8 dup(?),'$'
namectr db 0
endaddr dw ?
swapped db 0
messg1 db 'Input name:','$'
messg2 db 'Input a telephone number:','$'
messg3 db 'The sorted telephone number table:','$'
messg4 db 'Do you want a telephone number?(y/n)','$'
messg5 db 'The telephone number is not finded.','$'
messg6 db 'name tel. ','$'
messg7 db 13,10,'$'
;*************************************************************************
.code
;------------------------------------------------------------------------
main proc far
start:
mov ax,@data
mov ds,ax
mov es,ax
;
cld
lea di,tel_tab
a10loop: call input_name
cmp actname,0
jz a20
cmp namectr,50
je a20
call stor_name
call input_phone
jmp short a10loop
a20: cmp namectr,1
jbe a60
call name_sort
call name_display
a30: call crlf
lea dx, messg4
mov ah,9
int 21h
a40: mov ah,1
int 21h
cmp al,'n'
je a60
cmp al,'y'
je a50
jmp short a30
a50: call input_name
call name_search
jmp short a30
a60: mov ax,4c00h
int 21h
main endp
;---------------------------------------------------------------------------
input_name proc near
call crlf
lea dx,messg1
mov ah,9
int 21h
lea dx,namepar
mov ah,10
int 21h
call crlf
;
mov bh,0
mov bl,actname
mov cx,21
sub cx,bx
b10: mov namefld[bx],20h
inc bx
loop b10
ret
input_name endp
;--------------------------------------------------------------------------
stor_name proc near
inc namectr
lea si,namefld
mov cx,10
rep movsw
ret
stor_name endp
;-------------------------------------------------------------------------
input_phone proc near
lea dx,messg2
mov ah,9
int 21h
lea dx,phonepar
mov ah,10
int 21h
call crlf
;
mov bh,0
mov bl,actphone
mov cx,9
sub cx,bx
b20: mov phonefld[bx],20h
inc bx
loop b20
;
lea si,phonefld
mov cx,4
rep movsw
ret
input_phone endp
;--------------------------------------------------------------------------
name_sort proc near
sub di,28
mov endaddr,di
c10: mov swapped,0
lea si,tel_tab
c20: mov cx,20
mov di,si
add di,28
mov ax,di
mov bx,si
repe cmpsb
jbe c30
call c20xchg
c30: mov si,ax
cmp si,endaddr
jb c20
c40: cmp swapped,0
jnz c10
ret
name_sort endp
;------------------------------------------------------------------------
c20xchg proc near
mov cx,14
lea di,namesav
mov si,ax
rep movsw
;
mov cx,14
mov si,bx
mov di,ax
rep movsw
;
mov cx,14
lea si,namesav
mov di,bx
rep movsw
mov swapped,1
ret
c20xchg endp
;-----------------------------------------------------------------------
name_display proc near
lea dx,messg3
mov ah,9
int 21h
call crlf
mov bh,namectr
lea si,tel_tab
d10: lea di,namesav
mov cx,14
rep movsw
lea dx,namesav
mov ah,9
int 21h
call crlf
dec bh
jnz d10
ret
name_display endp
;------------------------------------------------------------------------
name_search proc near
mov bl,namectr
lea di,tel_tab
e10: mov cx,20
lea si,namefld
mov ax,di
repe cmpsb
jz e20
mov di,ax
add di,28
dec bl
jnz e10
lea dx,messg5
mov ah,9
int 21h
call crlf
jmp short e30
e20: mov cx,14
mov si,ax
lea di,namesav
rep movsw
call printline
e30: ret
name_search endp
;--------------------------------------------------------------------------
printline proc near
lea dx,messg6
mov ah,9
int 21h
call crlf
lea dx,namesav
mov ah,9
int 21h
call crlf
ret
printline endp
;-------------------------------------------------------------------------
crlf proc near
lea dx,messg7
mov ah,9
int 21h
ret
crlf endp
;--------------------------------------------------------------------------
;**************************************************************************
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -