资源描述:
《微型计算机原理 王忠民 课后答案 汇编语言程序设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第五章汇编语言程序设计1.画图说明下列语句所分配的存储空间及初始化情况。(1)42H59H54H45H00HEEH00H07H01H02H01H02H07H00H07H01H02H01H02H07H00H07H01H02H01H02H07H(2)00H00H01H00H02H00H00H00H01H00H02H00H00H00H01H00H02H00H00H00H01H00H02H00H00H00H01H00H02H00H07H00HFBHFFH59H42H45H54H02H56H2.(PLENTH)=22H;它表示数据与的长度3.(L)=06H4.(
2、1)MOVBXOFFSETLNAME(2)MOVSIWORDPTRCODE_LIST(3)MOVCODE_LENGTHEQU$-CODE_LIST5.(AX)=10(BL)=10(CL)=16.(1).(AX)=1(2).(AX)=2(3).(CX)=20(4).(DX)=40(5).(CX)=17.是说明下列指令中那些需要加上PR伪指令定义符。(1).不需要(2)不需要(3)SUB[BX],WORDBYTE2(或其他形式)(4).MOVCL,BYTEPTRWVAL8.编一宏定义BXCHG,将一字节高4位和低4位交换。BXCHGMARCOOPRMOVA
3、L,OPRMOVCL,04HROLAH,CLRORAL,CLORAH,ALMOVOPR,AHENDM9.已知宏定义,展开宏调用:OPPBH,BL,CH,CL+MOVAX,BX+XCHGAL,CL+MOVAX,BL+XCHGAL,CH+MOVBL,AL10.将寄存器中的16位数分成四组,每组四位,分别存放在AL,BL,CL和DL中。MOVCH,04HMOVCL,ALMOVDL,ALSHRCL,CHANDDL,AHMOVAL,AHMOVBL,AHSHRAL,CHANDBL,0FH11.试编写一程序,要求比较两个字符串STRING1和STRING2所含字符是
4、否相同,若相同则显示MATCH,若不相同则显示NOMATCH.解:DATASEGMENTSTRING1DB‘ABCDE’STRING2DB‘ABCDEF’MESG1DB‘MATCH$’MESG2DB‘MATCH$’DATAENDSSTACKSEGMENTBUFDB100DUP(?)STACKENDSCODESEGMENTMAINPROCFARSTART:PUSHDSMOVAX,0PUSHAXPUSHESMOVAX,DATAMOVDS,AXMOVAL,STRING1MOVCL,6MOVSI,OFFSETSTRING1MOVDI,OFFSETSTRING2
5、CLDREPECMPSBJZALLMATCHMOVDXOFFSETMESG2MOVAH,9INT21HRETALLMATCH:MOVDXOFFSETMESG1MOVAH9MOV21HRETMAINENDPCODEENDSENDSTART13.编写程序,将一个包含有20个数据的数组M分成两个数组,正数组P和负数组,分别把这两个数组中的数据的个数显示出来。解:DATASEGMENTMDB1,2,3,4,5,6,7,8,9,10DB-1,-2,-3,-4,-5,-6,-7,-8,-9,-10PDB20DUP(?)NDB20DUP(?)DATAENDSCODE
6、SEGMENTMAINPROCFARSTART:PUSHDSMOVAX,0PUSHAXMOVAX,DATAMOVDS,AXMOVAL,0MOVSIOFFSETMMOVCX20HLOOP1:MOVBL,M[SI]CMPAL,M[SIJAELOOP2MOVN,BLINCSICMPCX,20HJZLOOP3JMPLOOP1LOOP2:DECCXMOVP,BLINCSICMPCX,20HJZLOOP3JMPLOOP1LOOP3:MOVDX,OFFSETPMOVAH,9INT21HMOVDX,OFFSETNMOVAH,9INT21HRETMAINENDPCODE
7、ENDSENDSTART20.编写程序,求字节变量BVAR中的压缩BCD数转换为二进制数,并存入原变量中。解:DATASEGMENTBVARDW53H,00HDATAENDSCODESEGMENTMAINPROCFARASSUMECS:CODE,DS:DATASTART:PUSHDSMOVAX,0PUSHDS,AXMOVAX,DATAMOVDS,AXMOVAL,BYTEPTRSWMOVAH,ALANDAX,0F00FHMOVCL,4SHLAH,CLMOVSW,AXRETMAINENDPCODEENDSENDSTART