?? phone.asm
字號:
datasg segment 'data'
mess1 db 'Input name:','$'
mess2 db 'Input a telephone number:','$'
mess3 db 'Do you want a telephone number?(Y/N)','$'
mess4 db 'name?','$'
mess5 db 'name',16 dup(' '),'tel.',13,10,'$'
mess6 db 'Input error!',13,10,'$'
mess7 db 'Not in the table!',13,10,'$'
crlf db 13,10,'$'
namepar label byte
maxnlen db 21
namelen db ?
namefld db 21 dup(?)
telpar label byte
maxtlen db 9
tellen db ?
telfld db 9 dup(?)
tel_tab db 5 dup(20 dup(' '),8 dup(' '))
temp db 20 dup(' '),8 dup(' '),13,10,'$'
count db 0
endaddr dw ?
swapped db 0
datasg ends
codesg segment 'code'
assume cs:codesg,ds:datasg,es:datasg
main proc far
push ds
sub ax,ax
push ax
mov ax,datasg
mov ds,ax
mov es,ax
cld
lea di,tel_tab
start:
cmp count,5
je s1
mov ah,09
lea dx,mess1
int 21h
call input_name
call stor_name
call inphone
jmp start
s1:
cmp count,1
jbe s3
call name_sort
call disp
s2:
lea dx,mess3
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'N'
je exit
cmp al,'n'
je exit
cmp al,'Y'
je s3
cmp al,'y'
je s3
mov ah,09
lea dx,crlf
int 21h
lea dx,mess6
mov ah,09h
int 21h
jmp s2
s3:
mov ah,09
lea dx,crlf
int 21h
lea dx,mess4
mov ah,09
int 21h
call input_name
call name_search
call printline
jmp s2
exit:
ret
input_name proc near
mov ah,0ah
lea dx,namepar
int 21h
mov ah,09
lea dx,crlf
int 21h
mov bh,0
mov bl,namelen
mov cx,21
sub cx,bx
i1:
mov namefld[bx],20h
inc bx
loop i1
ret
input_name endp
inphone proc near
mov ah,09
lea dx,mess2
int 21h
mov ah,0ah
lea dx,telpar
int 21h
mov ah,09
lea dx,crlf
int 21h
mov bh,0
mov bl,tellen
mov cx,9
sub cx,bx
i2:
mov telfld[bx],20h
inc bx
loop i2
cld
lea si,telfld
mov cx,4
rep movsw
ret
inphone endp
stor_name proc near
inc count
cld
lea si,namefld
mov cx,10
rep movsw
ret
stor_name endp
name_sort proc near
sub di,56
mov endaddr,di
n1:
mov swapped,0
lea si,tel_tab
n2:
mov cx,20
mov di,si
add di,28
mov ax,di
mov bx,si
repe cmpsb
jbe n3
call change
n3:
mov si,ax
cmp si,endaddr
jbe n2
cmp swapped,0
jnz n1
ret
name_sort endp
change proc near
mov cx,14
lea di,temp
mov si,bx
rep movsw
mov cx,14
mov di,bx
rep movsw
mov cx,14
lea si,temp
rep movsw
mov swapped,1
ret
change endp
disp proc near
lea dx,mess5
mov ah,09
int 21h
lea si,tel_tab
d1:
lea di,temp
mov cx,14
rep movsw
mov ah,9
lea dx,temp
int 21h
dec count
jnz d1
ret
disp endp
name_search proc near
lea si,tel_tab
mov bx,si
add endaddr,28
n10:
lea di,namefld
mov cx,10
repe cmpsw
jcxz n30
add bx,28
mov si,bx
cmp si,endaddr
jbe n10
n20:
mov cx,-1
ret
n30:
mov si,bx
lea di,temp
mov cx,14
rep movsw
ret
name_search endp
printline proc near
cmp cx,-1
je p1
mov ah,09h
lea dx,mess5
int 21h
mov ah,09h
lea dx,temp
int 21h
ret
p1:
mov ah,09h
lea dx,mess7
int 21h
ret
printline endp
main endp
codesg ends
end main
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -