您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 汇编实验三报告-分类统计字符个数COUNT-CHAR
计算机学院计算机科学与技术专业8班学号姓名协作者_________教师评定_________________实验题目实验用2.3分类统计字符个数COUNT_CHAR一、实验目的与要求学习用汇编语言编写与设计分支循环程序。题目:分类统计字符个数COUNT_CHAR二、实验内容程序接收用户键入的一行字符(字符个数不超过80个,该字符串用回车符结束),并按字母、数字及其它字符分类计数,然后将结果存入以letter、digit和other为名的存储单元中。三、程序代码;******************************************Datasegmentstring1db'Inputyourstring:$'string2db'Digit:$'string3db'Letter:$'string4db'Other:$'Digitdb0Letterdb0Otherdb0dataends;*******************************************prognamsegment;-----------------------------------------------------------------mainprocfarassumecs:prognam,ds:datastart:pushds;保留现场subax,axpushaxmovax,datamovds,axleadx,string1;输出string1movah,9int21hmovcx,80L1:movah,1;输入字符int21hcmpal,0dh;若是回车则结束jzovercmpal,30h;若小于30h(0)则others+1jbotherscmpal,39h;若大于39h(9)则跳转L2继续比较jaL2jmpdigits;否则digits+1L2:cmpal,41h;若小于41h(A)则others+1jbotherscmpal,5ah;若大于5ah(Z)则跳转L3继续比较jaL3jmpletters;否则letters+1L3:cmpal,61h;若小于61h(a)则others+1jbotherscmpal,7ah;若大于7ah(z)则others+1jaothersjmpletters;否则letters+1digits:incdigitjmpover1others:incotherjmpover1letters:incletterjmpover1over1:loopL1over:callendlineleadx,string2;输出string2movah,9int21hsubax,axmoval,digitcalldisplaycallendlineleadx,string3;输出string3movah,9int21hsubax,axmoval,lettercalldisplaycallendlineleadx,string4;输出string4movah,9int21hsubax,axmoval,othercalldisplayretmainendp;------------------------------------------------------------------------------endlineprocnear;输出回车与换行movah,2movdl,0ahint21hmovah,2movdl,0dhint21hretendlineendp;-----------------------------------------------------------------------------------displayprocnear;输出结果movdl,aladddl,30h;0的ascii码是30movah,2int21hretdisplayendp;---------------------------------------------------------------------------------------prognamends;*********************************************************endstart四、运行结果附录:由于这个实验一开始做错了题目,实验课上机检查是检查了该程序实验2.2查找匹配字符串程序代码:;---------------------------------------------newlinemacro;回车换行的宏定义movah,02hmovdl,0dhint21hmovah,02hmovdl,0ahint21hendm;------------------------------------------------datasegmentmaxlenkdb8;关键字的最大长度factlenkdb?;关键字的实际长度keyworddb8dup(?);关键字的存储maxlensdb32;字符串的最大长度factlensdb?;字符串的实际长度sentencedb32dup(?);字符串的存储info1db'EnterKeyword:$'info2db'EnterSentence:$'mess0db'Matchatlocation:$'mess1db'Nomatch.$'mess2db?,?,'Hofthesentence.$'dataends;------------------------------------------------------stacksegmentstackstackends;------------------------------------------------------codesegment;------------------------------------------------------mainprocfarassumecs:code,ds:data,es:data,ss:stackstart:pushdssubax,axpushaxmovax,datamovds,axmoves,axmovah,09h;输出字符串信息leadx,info1int21hmovah,0ah;输入关键字leadx,maxlenkint21hbegin:newlinemovah,09hleadx,info2int21hmovah,0ah;输入字符串leadx,maxlensint21hnewlineleasi,keyword;关键字的首地址赋予sileabx,sentence;字符串的首地址赋予bxleadi,sentence;字符串的首地址赋予dimovdl,00h;对dl清零cld;方向标志位清零,字符串地址递增again:movcl,factlenkrepzcmpsbjzmatchmoval,factlenssubal,factlenkjsnext1incalleasi,keywordincbxmovdi,bxincdxcmpdl,aljlagainnext1:leadx,mess1movah,09hint21hjmpbeginmatch:leadx,mess0movah,09hint21hmovax,bxleabx,sentencesubax,bxmovbx,0001haddax,bxandax,00ffhxchgax,bxmovch,2rotate:movcl,4hrolbl,clmoval,blandal,0fhaddal,30hcmpal,3ahjlprintaddal,7hprint:movah,02hmovdl,alint21hdecchjnzrotatemovah,09hleadx,mess2int21hjnlbeginretmainendpcodeendsendstart运行结果:
本文标题:汇编实验三报告-分类统计字符个数COUNT-CHAR
链接地址:https://www.777doc.com/doc-5155540 .html