TITLE 电话本程序
include Irvine32.inc
CR=09H
LF=00H
.data
strTitle byte "电话查询系统(注意一定要先添加号码否则将溢出)",CR,LF,0
strTitle1 byte "版权所有欢迎使用.blog.asp?name=mjc000",CR,LF,0
strAddNew byte "1.条件号码",CR,LF,0
strQur byte "2.查询",CR,LF,0
strDel byte "3.删除",CR,LF,0
strExit byte "4.退出",CR,LF,0
strInfo byte "请选择您要的功能选项: ",0
strInput_name byte "请输入姓名: ",0
strInput_Num byte "请输入电话号码: ",0
strInputInfoQre byte "请输入和姓名相关的信息(按ENTER看全部记录): ",0
strNull byte " ",0
LengthIn_str dword 0
BuffName byte 200 dup (16 dup (0))
BuffNum byte 200 dup (16 dup (0))
RecordCount dword 0
RecordIndex dword 0
InputName byte 16 dup(0)
.code
main proc
call ShowMenu
call readchar
cmp al,'1'
jz _AddNew
cmp al,'2'
jz _Qur
cmp al,'3'
jz _Del
cmp al,'4'
jz _exit
jmp main
_AddNew:
call AddNew
jmp main
_Qur:
call Qur
call WaitMsg
jmp main
_del:
call del
jmp main
_exit:
exit
main endp
;-------------------------------------
;下面的函数ShowMenu完成显示界面
;
ShowMenu proc
mov eax,blue+(green*16)
call settextcolor
call clrscr
mov dh,4
mov dl,11
call gotoxy
mov edx,offset strTitle
call Writestring
mov dh,0
mov dl,0
call gotoxy
mov edx,offset strTitle1
call Writestring
mov dh,6
mov dl,32
call gotoxy
mov edx,offset strAddNew
call Writestring
mov dh,8
mov dl,32
call gotoxy
mov edx,offset strQur
call Writestring
mov dh,10
mov dl,32
call gotoxy
mov edx,offset strDel
call Writestring
mov dh,12
mov dl,32
call gotoxy
mov edx,offset strExit
call Writestring
mov dh,14
mov dl,32
call gotoxy
mov edx,offset strInfo
call Writestring
ret
ShowMenu endp
;-----------------------------------------
;-------------------------------------
;下面的函数AddNew完成添加新记录
;
AddNew proc
call crlf
mov edx,offset strInput_name
call Writestring
mov eax,16
mul RecordCount
mov edx,offset BuffName
add edx,eax
mov ecx,16
call readstring
mov edx,offset strInput_Num
call Writestring
mov eax,16
mul RecordCount
mov edx,offset BuffNum
add edx,eax
mov ecx,16
call readstring
inc RecordCount
ret
AddNew endp
;-----------------------------------------
;-------------------------------------
;下面的函数Qur完成查询功能
;
Qur proc
call crlf
mov edx,offset strInputInfoQre
call writestring
mov edx,offset inputname
call readstring
mov al,[edx]
cmp al,0
jnz QurInfo
mov ecx,16
mov ecx,RecordCount
mov ebx,-16
mov RecordIndex,0
shownextRecord:
add ebx,16
mov edx,offset buffName
add edx,ebx
call writestring
mov edx,offset strNull
call writestring
mov edx,offset buffNum
add edx,ebx
call writestring
call crlf
loop shownextRecord
jmp QurEnd
QurInfo:
mov ecx,RecordCount
add ecx,1
mov ebx,-16
mov edx,offset buffName
nextRecord:
add ebx,16
add edx,ebx
mov edi,edx
recmp:
cld
mov esi,offset inputname
mov al,[esi]
repnz scasb
jnz check_r_isend
push edi
push edx
mov edx,offset inputname
call LengthofStr
pop edx
nextch:
mov al,[esi+1]
cmp al,[edi]
jnz rescan
dec lengthIn_str
jz showthis
inc esi
inc edi
jmp nextch
rescan:
pop edi
jmp recmp
check_r_isend:
dec ecx
jz QurEnd
jmp nextRecord
showthis:
QurEnd:
ret
Qur endp
;-----------------------------------------
;-------------------------------------
;下面的函数Del完成删除指定记录
;
Del proc
ret
Del endp
;-----------------------------------------
;-------------------------------------
;下面的函数LengthofStr完成求得字符串的字符个数
;返回值:字符串长度 存放在LengthIn_str中
;参数:edx ,事先把要处理的字符串的首地址存放到edx中
LengthofStr proc
push eax
mov lengthIn_str,0
Length_L1:
mov al,[edx]
cmp al,0
jz Lend
inc lengthIn_str
inc edx
jmp Length_L1
Lend:
pop eax
ret
LengthofStr endp
;-----------------------------------------
end main