您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 其它文档 > 北京理工大学汇编语言练习题及答案1
一、1.请任意输入一个字符串,将该串倒序后在屏幕上显示。DATASSEGMENTBUFDB40DB?DB40DUP(0)ACCDB0CHARDB?DATASENDSSTACKSSEGMENTDB100DUP(0)STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVAH,0AHLEADX,BUFINT21H;输入字符串MOVAH,0EHMOVAL,0DHINT10HMOVAL,0AHINT10H;回车换行LEASI,BUFMOVAL,[SI+1]MOVAH,0MOVACC,ALINCSIADDSI,AXL1:MOVDL,[SI]MOVAH,02HINT21HDECSIDECACCCMPACC,0JNZL1MOVAH,4CHINT21HCODESENDSENDSTART2.请任意输入一个字符串,统计其中空格和A的个数,并将结果显示在屏幕上。DATASEGMENTBUFDB100DB?DB100DUP(?)CHARDB0ACCDB0SPACEDB0CHARADB0DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMEDS:DATA,CS:CODEMAINPROCFARMOVAX,DATAMOVDS,AXLEADX,BUFMOVAH,0AHINT21H;输入字符串MOVAH,02HMOVDL,0DHINT21HMOVDL,0AHINT21HLEASI,BUFMOVAL,[SI+1]MOVACC,ALMOVSI,2L:CMPBUF[SI],''JZLSPACECMPBUF[SI],'A'JZLCHARAINCSIDECACCCMPACC,0JZSHOWJMPLLSPACE:INCSPACEINCSIDECACCCMPACC,0JZSHOWJMPLLCHARA:INCCHARAINCSIDECACCCMPACC,0JZSHOWJMPLSHOW:CMPSPACE,0AHJAESHOWSADDSPACE,30HMOVDL,SPACEMOVAH,2INT21H;若SPACE小于10个,直接输出个数SHOW1:MOVAH,0EHMOVAL,0DHINT10HMOVAL,0AHINT10HCMPCHARA,0AHJAESHOWAADDCHARA,30HMOVAH,2MOVDL,CHARAINT21H;若A个数小于10,直接输出个数JMPEXITSHOWS:MOVAL,SPACEMOVAH,0MOVDL,10DIVDLADDAH,30HMOVSPACE,AHADDAL,30HMOVAH,2MOVDL,ALINT21HMOVDL,SPACEINT21HJMPSHOW1SHOWA:MOVAL,CHARAMOVAH,0MOVDL,10DIVDLADDAH,30HMOVCHARA,AHADDAL,30HMOVAH,2MOVDL,ALINT21HMOVDL,CHARAINT21HEXIT:MOVAH,4CHINT21HMAINENDPCODEENDSENDMAIN3.请任意输入一个字符串,将其中的空格全部删除,并将结果显示在屏幕上。DATASEGMENTBUFDB100DB?DB100DUP(?)INPDB'Pleaseinputastring:','$'CHARDB0ACCDB0DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMEDS:DATA,CS:CODE,ES:STACKSTART:MOVAX,DATAMOVDS,AX;赋初值MOVAH,09HLEADX,INPINT21H;提示输入MOVAH,0AHLEADX,BUFINT21H;输入字符串MOVAH,2MOVDL,0DHINT21HMOVDL,0AHINT21H;回车换行LEASI,BUFMOVDL,[SI+1]MOVACC,DLMOVSI,2LOP:MOVDL,BUF[SI]MOVCHAR,DLCMPCHAR,''JZLADDMOVAH,2MOVDL,CHARINT21H;若不是空格则输出LADD:INCSIDECACCCMPACC,0JZEXITJMPLOPEXIT:MOVAH,4CHINT21HCODEENDSENDSTART4.请任意输入一个字符串,将其中A换成B,并将结果显示在屏幕上。DATASEGMENTINPDB'Pleaseinputastring:','$'CHARDB0ACCDB0BUFDB50DB?DB50DUP(0)DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAH,9LEADX,INPINT21H;提示输入字符串MOVAH,0AHLEADX,BUFINT21HMOVAH,2MOVDL,0DHINT21HMOVDL,0AHINT21H;输入字符串LEASI,BUFMOVDL,[SI+1]MOVACC,DL;记录字符串个数MOVSI,2MOVAH,2LA:MOVDL,BUF[SI]CMPDL,'A'JZPUTCCINT21HLAD:INCSIDECACCMOVDH,ACCCMPDH,0JZEXITJMPLAPUTCC:MOVDL,'C'INT21HINT21HJMPLADEXIT:MOVAH,4CHINT21HCODEENDSENDSTART5.请任意输入一个字符串,将其中A换成CC,并将结果显示在屏幕上。DATASEGMENTINPDB'Pleaseinputastring:','$'CHARDB0ACCDB0BUFDB50DB?DB50DUP(0)DATAENDSSTACKSEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAH,9LEADX,INPINT21H;提示输入字符串MOVAH,0AHLEADX,BUFINT21HMOVAH,2MOVDL,0DHINT21HMOVDL,0AHINT21H;输入字符串LEASI,BUFMOVDL,[SI+1]MOVACC,DL;记录字符串个数MOVSI,2MOVAH,2LA:MOVDL,BUF[SI]CMPDL,'A'JZPUTCCINT21HLAD:INCSIDECACCMOVDH,ACCCMPDH,0JZEXITJMPLAPUTCC:INT21HINT21HJMPLADEXIT:MOVAH,4CHINT21HCODEENDSENDSTART6.请任意输入一个字符串,将其中大写字母换成小写字母,并将结果显示在屏幕上。DATASEGMENTINPDB'Pleaseinputastring:','$'CHARDB0ACCDB0BUFDB50DB?DB50DUP(0)DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAH,9LEADX,INPINT21H;提示输入字符串MOVAH,0AHLEADX,BUFINT21HMOVAH,2MOVDL,0DHINT21HMOVDL,0AHINT21H;输入字符串LEASI,BUFMOVDL,[SI+1]MOVACC,DL;记录字符串个数MOVSI,2MOVAH,2LA:MOVDL,BUF[SI]CMPDL,'A'JBPUTCMPDL,'Z'JBEPUTCHGPUT:INT21HJMPLADPUTCHG:ADDDL,32INT21HLAD:INCSIDECACCMOVDH,ACCCMPDH,0JZEXITJMPLAEXIT:MOVAH,4CHINT21HCODEENDSENDSTART7.请任意输入一个字符串,将其中的英文字母全部删除,并将结果显示在屏幕上。DATASEGMENTINPDB'Pleaseinputastring:','$'CHARDB0ACCDB0BUFDB50DB?DB50DUP(0)DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAH,9LEADX,INPINT21H;提示输入字符串MOVAH,0AHLEADX,BUFINT21HMOVAH,2MOVDL,0DHINT21HMOVDL,0AHINT21H;输入字符串LEASI,BUFMOVDL,[SI+1]MOVACC,DL;记录字符串个数MOVSI,2MOVAH,2LA:MOVDL,BUF[SI]CMPDL,'A'JBPUTCMPDL,'Z'JBELADCMPDL,'a'JBPUTCMPDL,'z'JBELADPUT:INT21HJMPLADLAD:INCSIDECACCMOVDH,ACCCMPDH,0JZEXITJMPLAEXIT:MOVAH,4CHINT21HCODEENDSENDSTART
本文标题:北京理工大学汇编语言练习题及答案1
链接地址:https://www.777doc.com/doc-4848537 .html