资源描述:
《微机原理与接口技术习题标准答案()》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、微机原理与接口技术习题答案4(1)————————————————————————————————作者:————————————————————————————————日期:2第4章汇编语言程序设计1.已知在BUF的起始处保存有N个字符的ASCII码,编写汇编语言程序实现,将这组字符串传送到缓冲区BUFR中,并且使字符串的顺序与原来的顺序相反。解:BUFDB"BONJOUR_BELLE"BUFRDB100DUP(?)MOVCX,NLEASI,BUFLEADI,BUFRADDDI,CXDECDIL1:M
2、OVAL,[SI]MOV[DI],ALINCSIDECDILOOPL12.利用移位、传送和相加指令实现AX的内容扩大10倍。解:将扩大后的结果放在DX:AX中,注意到10×AX=8×AX+2×AX。XORDX,DXSHLAX,1RCLDX,1MOVBX,AXMOVCX,DXSHLAX,1RCLDX,1SHLAX,1RCLDX,1ofaccountability,redressofordersandprohibitions.Strengtheningthehonestyandself-disciplin
3、eofleadingcadreshonestyinpoliticsandeducationwork,enhanceleadersabilitytoresistADDAX,BXADCDX,CX1.在缓冲区VAR中连续存放着3个16位的无符号数,编写程序实现将其按递增关系排列;如果VAR中保存的为有符号数,则再编写程序实现将其按递减关系排列。解:VARDW1236,-432,3900XORSI,,SIMOVAX,VAR[SI]CMPAX,VAR[SI+2]JAEL1XCHGAX,VAR[SI+2]L1:C
4、MPAX,VAR[SI+4]JAEL2XCHGAX,VAR[SI+4]L2:MOVVAR[SI],AXMOVAX,VAR[SI+2]CMPAX,VAR[SI+4]JAEL3XCHGAX,VAR[SI+4]L3:MOVVAR[SI+2],AX2.编写程序段实现将AL和BL中的每一位依次交叉,得到的16位字保存在DX中,例如(AL)=01100101B,(BL)=11011010B,则得到的(DX)=1011011010011001B。解:利用移位指令完成。XORDX,DXMOVCX,8L1:SHRAL,
5、1ofaccountability,redressofordersandprohibitions.Strengtheningthehonestyandself-disciplineofleadingcadreshonestyinpoliticsandeducationwork,enhanceleadersabilitytoresistRCRDX,1SHRBL,1RCRDX,1LOOPL11.在变量VAR1和VAR2中分别保存有两个字节型的正整数,编写完整的汇编语言程序实现:(1)当两数中有一个奇数时,
6、将奇数存入VAR1,偶数存入VAR2;(2)当两数均为奇数时,两个变量的内容不变;(3)当两数均为偶数时,两数缩小一倍后存入原处。解:当VAR1为奇数时,不论VAR2的奇偶性,这两个单元的内容均不变;只有当VAR1为偶数时,如果VAR2为奇数,则VAR1与VAR2内容交换;如果VAR2为偶数,则两数缩小一倍后存入原处。DATASEGMENTVAR1DB28VAR2DB36DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATASTART:MOVAX,DATAMO
7、VDS,AXMOVES,AXMOVAL,VAR1MOVBL,VAR2TESTAL,1JZEVEN1JMPOVEREVEN1:TESTBL,1JZEVEN2ofaccountability,redressofordersandprohibitions.Strengtheningthehonestyandself-disciplineofleadingcadreshonestyinpoliticsandeducationwork,enhanceleadersabilitytoresistMOVVAR1,B
8、LMOVVAR2,ALJMPOVEREVEN2:SHRAL,1MOVVAR1,ALSHRBL,1MOVVAR2,BLOVER:MOVAH,4CHMOVAL,0INT21HCODEENDSENDSTART1.已知在字变量VAR1、VAR2和VAR3中保存有3个相同的代码,但有一个错码,编写程序段找出这个错码,并将它送到AX,其地址送SI;如果3个代码都相同,则在AX中置-1标志。解:在数据段中定义:VAR1DW5A34HVAR2DW5A35HVAR3DW3