精品字典汇编程序.docx
《精品字典汇编程序.docx》由会员分享,可在线阅读,更多相关《精品字典汇编程序.docx(54页珍藏版)》请在冰豆网上搜索。
精品字典汇编程序
字典汇编程序
实验报告
实验目的
综合运用已学知识独立完成课程设计,熟练掌握汇编语言程序设计的基础知识。
实验题目
简易英英词典
功能要求:
1.单词及其英文解释的录入、修改和删除
(1)录入的新单词,把它插入到相应的位置(和一般词典一样);
(2)可修改单词英文解释;
(3)删除单词及其英文解释;
2.查找:
(1)输入不完整的字符串,会依顺序列出单词前缀和字符串相匹配的单词;
如输入:
en
列出:
enable,enabled,enact等
(2)查询某个单词英文解释(如enable:
toprovidewiththemeansoropportunity;tomake
possible,practical,oreasy),词库中不存在此单词,则提示找不到;
(3)查询某个单词的同义词(如accept:
approve);
(4)查询某个单词的反义词(如win:
lose);
3.显示:
界面美观
实验内容
一、数据文件结构说明
1、每个词义(共4个)占64字节,近义词占64字节,反义词占64字节,均以$结束。
2、单词索引表置于文件尾,每个索引项中单词占22字节(包含结束符$),单词信息块位置信息占2字节。
单词索引表以空格组成的串为结束标志。
3、文件最末尾的6个字节,分别记录单词索引表中单词个数(包含空格组成的串),单词索引表距文件首的字节数(依次为高位字、低位字)。
一、功能模块及主要宏、函数
1、查询模块
(1)、mycmps
功能:
字符串比较
参数:
mycmpstab[0]字符串1偏移地址;mycmpstab[2]字符串2偏移地址。
返回:
str1str2CF=0,ZF=0。
(2)、halfsearch
功能:
字符串查找(折半)
参数:
halfsearchtab[0]字符串缓冲区偏移地址;halfsearchtab[2]字符串个数;
halfsearchtab[4]查询字符串偏移地址;halfsearchtab[6]字符串长度。
返回:
查找成功,CF=0,ax返回匹配串的偏移地址。
查找不成功,CF=1,ax返回查询串插入时偏移地址。
2、显示模块
(1)、displayword
功能:
显示单词前缀和字符串相匹配的单词
参数:
displaywordtab[0]字符串缓冲区偏移地址;displaywordtab[2]显示字符串个数;
displaywordtab[4]字符串长度;displaywordtab[6]亮行位置;
displaywordtab[8]返回光标位置;displaywordtab[10]实际显示字符串个数。
返回:
操作成功,displaywordtab[10]返回实际显示字符串个数,光标位于
displaywordtab[8]设置位置。
(2)、readwordinfo
功能:
读取单词解释、近义词、反义词信息
参数:
readwordinfotab[0]单词信息块位置;readwordinfotab[2]存放信息块缓冲区偏移地址;readwordinfotab[4]单词信息块大小。
返回:
操作成功,从文件中读取信息块于主存偏移地址为readwordinfotab[2]缓冲区中。
(3)、showasentence
功能:
显示一条单词信息
(4)、showwordinfo
功能:
显示单词信息
参数:
showwordinfotab[0]单词索引表中该单词的偏移地址;
showwordinfotab[2]单词信息缓冲区偏移地址;
showwordinfotab[4]单词信息块大小;
showwordinfotab[6]返回光标位置;
showwordinfotab[8]实际显示单词信息条数。
返回:
操作成功,显示单词信息,showwordinfotab[8]返回实际显示单词信息条数,光标位于showwordinfotab[6]设置位置。
3、编辑模块
(1)、indexinsert
功能:
在单词索引表中插入一个单词
参数:
indexinserttab[0]单词索引表偏移地址;indexinserttab[2]单词索引表单词个数;
indexinserttab[4]单词大小;indexinserttab[6]插入单词的偏移地址;
indexinserttab[8]插入位置偏移地址。
返回:
单词索引表中插入一个单词,完成索引表信息的维护。
(2)、indexdelete
功能:
在单词索引表中删除一个单词
参数:
indexdeletetab[0]单词索引表偏移地址;indexdeletetab[2]单词索引表单词个数;
indexdeletetab[4]删除位置偏移地址。
返回:
单词索引表中删除一个单词,完成索引表信息的维护。
(3)、inputnewinfo
功能:
接受新的单词信息
哑元:
bufad存放新的单词信息的缓冲区偏移地址;
maxindex最大下标值,信息中字符个数减结束符减1;
charperline输入时每行字符数;
specialpoint键入BackSpace需特殊处理的点;
wndb窗口属性;begincursor接受字符起始光标位置。
(4)、appdnewword
功能:
添加新的单词
(5)、editnotfind
功能:
完成未找到匹配单词时的编辑(添加操作)
参数:
editnotfindtab单词插入索引表位置偏移地址。
(6)、delallwordinfo
功能:
删除一个单词。
(7)、editfind
功能:
完成找到匹配单词时的编辑(修改、删除操作)
参数:
editfindtab单词插入索引表位置偏移地址。
4、文件处理模块
(1)、createfile
功能:
创建文件
参数:
createfiletab[0]ASCIZ串偏移地址;createfiletab[2]文件属性;
createfiletab[4]出错信息偏移地址;createfiletab[6]返回文件代号。
返回:
操作成功,createfiletab[6]返回文件代号,CF=0。
操作不成功,输出提示信息,CF=1。
(2)、openfile
功能:
打开文件
参数:
openfiletab[0]ASCIZ串偏移地址;openfiletab[2]出错信息偏移地址。
返回:
操作成功,handle返回文件代号,CF=0。
操作不成功,输出提示信息,CF=1。
(3)、movfp
功能:
移动文件指针
参数:
handle文件代号;movfptab[0]移动方式码;
movfptab[2]偏移字节数(高位);movfptab[4]偏移字节数(低位);
movfptab[6]出错信息偏移地址。
返回:
操作成功,CF=0。
操作不成功,输出提示信息,CF=1。
(4)、wrfile
功能:
读/写文件
参数:
handle文件代号;wrfiletab[0]读/写;
wrfiletab[2]数据缓冲区偏移地址;wrfiletab[4]读/写字节数;
wrfiletab[6]出错信息偏移地址。
返回:
操作成功,CF=0。
操作不成功,输出提示信息,CF=1。
5、绘制界面模块
(1)、drawwnd
功能:
绘制窗口
哑元:
attribute窗口属性;wndleftr左上角行号;wndleftc左上角列号;
wndrightr右上角行号;wndrihgtc右上角行号。
(2)、setcursor
功能:
设置光标位置
哑元:
page页号;row行号;column列号;
addp页号增量;addr行号增量;addc列号增量。
(3)、interface
功能:
绘制界面
(4)、operdeclare
功能:
显示操作说明
二、程序流程图
三、源程序
dsegsegment'data'
indexelemsizeequ24
wordmaxsizeequ23
wordinfosizeequ64
wordmeaningsizeequ384
Upequ48h
Downequ50h
Leftequ4Bh
BackSpaceequ08h
KeyEscequ1bh
Dollarequ24h
Enterequ0dh
dictionarydb"Weed'sDictionary1.0$"
inpmsgdb'Inputtheword:
$'
indexmsgdb'Index:
$'
welcomemsgdb"WelcometouseWeed'sDictionary1.0$"
pathmsgdb'Pleaseinputthepathofwords.dat$'
escmsgdb'Esc:
exit$'
entermsgdb'Enter:
edit$'
bslmsgdb'BackSpaceandLeft:
stepback$'
upmsgdb'Up:
lineup$'
downmsgdb'Down:
linedown$'
meaningmsgdb'Meaning:
$'
synonymsmsgdb'Synonyms:
$'
antonymmsgdb'Antonym:
$'
nofindmsg0db'NOFIND!
@_@$'
nofindmsg1db'PRESSENTERTOEDITTHEWORD!
~_~$'
editnotfindmsgdb'Append(A)$'
appendmsgdb'Append:
$'
editfindmsgdb'Modify(M)Delete(D)$'
modifymsgdb'Modify:
$'
deletemsgdb'Delete:
$'
optionmsg0db'Word(W)$'
optionmsg1db'Meaning(M)Synonyms(S)$'
optionmsg2db'Antonym(A)$'
optretmsgdb'Return(R):
$'
operfinmsgdb'Operationhasfinished!
*_*$'
retmsgdb"Enter'R'or'r'toreturn:
$"
nosynonymsmsgdb'nosynonyms$'
noantonymmsgdb'noantonym$'
meaningnomsgdb'MeaningNO.(1~4):
$'
savechgmsgdb'Savetheinformation?
Y/N$'
delmsmsgdb'Deletetheinformation?
Y/N$'
delnotemsgdb"LOSEALLWORD'SINFORMATION:
Y/N$"
mdfywdmsgdb"!
_!
REALLYTODOTHAT:
Y/N$"
crefilmsgdb'ERROR:
createfile()$'
opefilmsgdb'ERROR:
openfile()$'
movfpmsgdb'ERROR:
movfp()$'
wrfilemsgdb'ERROR:
wrfile()$'
clsfilmsgdb'ERROR:
closefile()$'
defaultpathdb'c:
\weeddic',0
wndone1rdb0
wndone1cdb0
wndone2rdb24
wndone2cdb79
wndonebdb96h
barone1rdb1
barone1cdb0
barone2rdb1
barone2cdb79
baronebdb70h
bartwo1rdb2
bartwo1cdb31
bartwo2rdb24
bartwo2cdb31
bartwobdb70h
wndtwo1rdb4
wndtwo1cdb3
wndtwo2rdb5
wndtwo2cdb26
wndtwobdb0fch
wndthree1rdb9
wndthree1cdb3
wndthree2rdb22
wndthree2cdb26
wndthreebdb0f2h
wndfour1rdb4
wndfour1cdb36
wndfour2rdb22
wndfour2cdb75
wndfourbdb0fdh
wndwel1rdb10
wndwel1cdb20
wndwel2rdb14
wndwel2cdb57
wndwelbdb0e0h
wndeditbdb0f5h
wndsavebdb0edh
wndeditnbdb0f6h
mycmpstabdw2dup(?
)
;str1adstr2ad
halfsearchtabdw4dup(?
)
;wordsadtablensearchwordadwordsize
indexinserttabdw5dup(?
)
;indexadindexlenwordsizeinswordadinsertad
indexdeletetabdw4dup(?
)
;indexadindexlenwordsizedeletead
displaywordtabdw7dup(?
)
;wordarraddisplaynumwordsizelightlineretcursorrealdispnum
showwordinfotabdw5dup(?
)
;wordadwordinfoadwordinfosizenonemptynumreturncursor
readwordinfotabdw?
;wordplace
inputpathdb37,0
pathnamedb37dup(?
)
handledw?
;share
createfiletabdw4dup(?
);ascizadfileattributemsgadrethandle
openfiletabdw2dup(?
);pathnamemsgad
movfptabdw4dup(?
);movfpwaymovfphmovfplmsgad
wrfiletabdw4dup(?
);w/r,bufferadsizemsgad
closefiletabdw?
;msgad
findflagdb?
cpyflagdb?
editnotfindtabdw?
;insertplace
editflagdb0;ifedit
editfindtabdw?
;deletead
indexinfodw3dup(?
)
searchworddb23dup(Dollar)
wordmeaninglabelbyte
wordm1db64dup(?
)
wordm2db64dup(?
)
wordm3db64dup(?
)
wordm4db64dup(?
)
similardb64dup(?
)
oppositedb64dup(?
)
wordsindexdb10000dup(?
)
dsegends
ssegsegmentstack'stack'
db256dup(0)
ssegends
csegsegment'code'
assumeds:
dseg,ss:
sseg,cs:
cseg
pushregistermacror1,r2,r3,r4
pushr1
pushr2
pushr3
pushr4
endm
popregistermacror1,r2,r3,r4
popr1
popr2
popr3
popr4
endm
drawwndmacroattribute,wndleftr,wndleftc,wndrightr,wndrihgtc
pushregisterax,bx,cx,dx
movax,0600h
movbh,attribute
movch,wndleftr
movcl,wndleftc
movdh,wndrightr
movdl,wndrihgtc
int10h
popregisterdx,cx,bx,ax
endm
setcursormacropage,row,column,addp,addr,addc
pushax
pushbx
pushdx
movah,2
movbh,page
addbh,addp
movdh,row
adddh,addr
movdl,column
adddl,addc
int10h
popdx
popbx
popax
endm
printcmacrochar
pushax
pushdx
movah,2
movdl,char
int21h
popdx
popax
endm
printstrmacrostrname
pushax
pushdx
movah,9
movdx,offsetstrname
int21h
popdx
popax
endm
putstrmacrostraddr
pushax
pushdx
movah,9
movdx,straddr
int21h
popdx
popax
endm
interfacemacro
drawwndwndoneb,wndone1r,wndone1c,wndone2r,wndone2c
drawwndbaroneb,barone1r,barone1c,barone2r,barone2c
drawwndbartwob,bartwo1r,bartwo1c,bartwo2r,bartwo2c
drawwndwndtwob,wndtwo1r,wndtwo1c,wndtwo2r,wndtwo2c
drawwndwndthreeb,wndthree1r,wndthree1c,wndthree2r,wndthree2c
drawwndwndfourb,wndfour1r,wndfour1c,wndfour2r,wndfour2c
setcursor0,0,28,0,0,0
printstrdictionary
setcursor0,3,3,0,0,0
printstrinpmsg
setcursor0,8,3,0,0,0
printstrindexmsg
endm
operdeclaremacro
setcursor0,wndfour1r,wndfour1c,0,1,3
printstrescmsg
setcursor0,wndfour1r,wndfour1c,0,2,3
printstrentermsg
setcursor0,wndfour1r,wndfour1c,0,3,3
printstrbslmsg
setcursor0,wndfour1r,wndfour1c,0,4,3
printstrupmsg
setcursor0,wndfour1r,wndfour1c,0,5,3
printstrdownmsg
endm
firstusemacro
drawwndwndwelb,wndwel1r,wndwel1c,wndwel2r,wndwel2c
setcursor0,wndwel1r,wndwel1c,0,1,1
printstrwelcomemsg
setcursor0,wndwel1r,wndwel1c,0,2,2
printstrpathmsg
setcursor0,wndwel1r,wndwel1c,0,3,1
movah,0ah
movdx,offsetinputpath
int21h
movbh,0
movbl,inputpath[1]
addbx,2
movinputpath[bx],0
movcreatefiletab[0],offsetdefaultpath
movcreatefiletab[2],02
movcreatefiletab[4],offsetcrefilmsg
callcreatefile
movax,createfiletab[6]
movhandle,ax
movwrfiletab[0],4000h
movwrfiletab[2],offsetinputpath[1]
movwrfiletab[4],bx
movwrfiletab[6],offsetcrefilmsg
callwrfile
movclosefiletab[0],offsetclsfilmsg
callclosefile
endm
notfirstusemacro
movwrfiletab[0],3f00h
movwrfiletab[2],offsetinputpath[1]
movwrfiletab[4],1
movwrfiletab[6],offsetwrfilemsg
callwrfile
movwrfiletab[2],offsetpathname
movah,0
moval,inputpath[1]
movwrfiletab[4],ax
callwrfile
movclo