⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phonebook_program.asm

📁 一个用Inter汇编写的电话薄程序
💻 ASM
字号:
title PhoneBook_program.asm
include irvine32.inc

list struct
dname      byte 10 dup(0)
six        byte 10 dup(0)
phonenum   byte 10 dup(0)
list ends

.data
msgfuntion byte "*******Telephone Book*********",0ah
	   byte "*   1.  Add a record.        *",0ah
	   byte "*   2.  Find a record.       *",0ah
	   byte "*   3.  Refresh a record.    *",0ah
	   byte "*   4.  Delete a record.     *",0ah
	   byte "*   5.  Exit the program.    *",0ah
	   byte "******************************",0ah,0
msgchoose  byte "Please choose a funtion:",0
msgwrong   byte "Wrong input.Please check and input again!",0ah,0ah,0
msgfunt11  byte "Please input the name:",0
msgfunt12  byte "Please input the six:",0
msgfunt13  byte "Please input the telephone number:",0
msgfunt14  byte "Add successful!",0ah,0ah,0
msgfunt21  byte "Please input the name of person you want to look for:",0
msgfunt22  byte "Nothing record from this person!",0
msgfunt30  byte "Please input the name of person you want to refresh record:",0
msgfunt31  byte "Please input refreshed name:",0
msgfunt32  byte "Please input refreshed six:",0
msgfunt33  byte "Please input refreshed telephone number:",0
msgfunt34  byte "Refresh successful!",0ah,0ah,0
msgfunt41  byte "Please input the name of person you want to delete record:",0
msgfunt42  byte "Delete successful!",0ah,0ah,0
msgexit    byte "Thank you for using this program!Good luck!",0ah,0
xnum       dword 10
count      dword 0
right      byte 0
person list 10 dup(<>)
fname  byte 10 dup(0)

.code
main proc
call clrscr
pmain:
call printmain
call readint
.if eax==1
call addrecord
jmp pmain
.endif
.if eax==2
call findrecord
jmp pmain
.endif
.if eax==3
call refreshrecord
jmp pmain
.endif
.if eax==4
call deleterecord
jmp pmain
.endif
.if eax==5
jmp quitproc
.endif
.if eax<1||eax>5
call clrscr
mov edx,offset msgwrong
call writestring
jmp pmain
.endif
quitproc:
call clrscr
mov edx,offset msgexit
call writestring
exit
main endp

printmain proc
mov edx,offset msgfuntion
call writestring
mov edx,offset msgchoose
call writestring
ret
printmain endp

addrecord proc
mov esi,count
mov edx,offset msgfunt11
call writestring
lea edx,(list ptr person[esi]).dname
mov ecx,9
call readstring
mov edx,offset msgfunt12
call writestring
lea edx,(list ptr person[esi]).six
mov ecx,9
call readstring
mov edx,offset msgfunt13
call writestring
lea edx,(list ptr person[esi]).phonenum
mov ecx,9
call readstring
mov edx,offset msgfunt14
call writestring
add count,type list
ret
addrecord endp

findrecord proc
mov edx,offset msgfunt21
call writestring
mov edx,offset fname
mov ecx,9
call readstring
mov ebx,0
find:
lea esi,fname
lea edi,(list ptr person[ebx]).dname
cld
mov ecx,9
repz cmpsb
jnz down
lea edx,(list ptr person[ebx]).dname
call writestring
call crlf
lea edx,(list ptr person[ebx]).six
call writestring
call crlf
lea edx,(list ptr person[ebx]).phonenum
call writestring
call crlf
call crlf
inc right
down:add ebx,type list
dec xnum
mov ecx,xnum
loop find
mov xnum,10
mov ecx,10
mov esi,0
lfname:mov fname[esi],0
inc esi
loop lfname
cmp right,0
jz showwrongf
jmp fquit
showwrongf:mov edx,offset msgfunt22
call writestring
fquit:call crlf
call crlf
mov right,0
ret
findrecord endp

refreshrecord proc
mov edx,offset msgfunt30
call writestring
mov edx,offset fname
mov ecx,9
call readstring
mov ebx,0
refind:
lea esi,fname
lea edi,(list ptr person[ebx]).dname
cld
mov ecx,9
repz cmpsb
jz refsh
add ebx,type list
dec xnum
mov ecx,xnum
inc right
loop refind
cmp right,9
jz showwrong2
refsh:mov edx,offset msgfunt31
call writestring
lea edx,(list ptr person[ebx]).dname
mov ecx,9
call readstring
mov edx,offset msgfunt32
call writestring
lea edx,(list ptr person[ebx]).six
mov ecx,9
call readstring
mov edx,offset msgfunt33
call writestring
lea edx,(list ptr person[ebx]).phonenum
mov ecx,9
call readstring
mov edx,offset msgfunt34
call writestring
jmp rquit
showwrong2:mov edx,offset msgfunt22
call writestring
rquit:mov xnum,10
mov ecx,10
mov esi,0
lrename:mov fname[esi],0
inc esi
loop lrename
call crlf
call crlf
mov right,0
ret
refreshrecord endp

deleterecord proc
mov edx,offset msgfunt41
call writestring
mov edx,offset fname
mov ecx,9
call readstring
mov ebx,0
defind:
lea esi,fname
lea edi,(list ptr person[ebx]).dname
cld
mov ecx,9
repz cmpsb
jz defsh
add ebx,type list
dec xnum
mov ecx,xnum
inc right
loop defind
cmp right,9
jz showwrong3
defsh:mov (list ptr person[ebx]).dname,0
mov edx,offset msgfunt42
call writestring
call crlf
jmp dquit
showwrong3:mov edx,offset msgfunt22
call writestring
dquit:mov xnum,10
mov ecx,10
mov esi,0
ldename:mov fname[esi],0
inc esi
loop ldename
call crlf
call crlf
mov right,0
ret
deleterecord endp

end main

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -