《微机原理课后答案周荷琴第四版》由会员分享,可在线阅读,更多相关《微机原理课后答案周荷琴第四版(21页珍藏版)》请在金锄头文库上搜索。
1、第三章作业习题课第三章作业习题课朱亚萍朱亚萍朱亚萍朱亚萍杭州电子科技大学自动化学院杭州电子科技大学自动化学院杭州电子科技大学自动化学院杭州电子科技大学自动化学院微机原理与接口技术2021/6/42021/6/41 12. 2. DS=1000H, BX=0200H, SI=0002HDS=1000H, BX=0200H, SI=0002H (10200H10205H)10200H10205H)依次存有依次存有10H,2AH,3CH,46H,59H,6BH10H,2AH,3CH,46H,59H,6BH(1 1)MOV AX, 0200H ; MOV AX, 0200H ; AX=0200AX=0
2、200(2 2)MOV AX, 200H MOV AX, 200H 物理地址物理地址=1000H10H+0200H=10200H, =1000H10H+0200H=10200H, AX=2A10HAX=2A10H(3 3)MOV AX, BX MOV AX, BX ; AX=0200H; AX=0200H(4 4)MOV AX , 3BX MOV AX , 3BX 物理地址物理地址=1000H10H +0200H+3H=10203H, =1000H10H +0200H+3H=10203H, AX=5946HAX=5946H(5 5)MOV AX , BX+SIMOV AX , BX+SI 物理
3、地址物理地址=1000H10H+0200H +2H=10202H , =1000H10H+0200H +2H=10202H , AX=463CHAX=463CH(6 6)MOV AX, 2BX+SIMOV AX, 2BX+SI 物理地址物理地址=1000H10H +200H+2H+2H=10204H , =1000H10H +200H+2H+2H=10204H , AX=6B59HAX=6B59H2021/6/42021/6/42 23.DS=1000H, ES=2000H, SS=3500H, 3.DS=1000H, ES=2000H, SS=3500H, SI=00A0H, DI=0024
4、H, BX=0100H, BP=0200H, VAL=0030H SI=00A0H, DI=0024H, BX=0100H, BP=0200H, VAL=0030H (1 1)MOV AX,MOV AX,100H 100H 直接寻址方式,直接寻址方式,10100H10100H 物理地址物理地址DS10H+100H=10000H+0100H=10100HDS10H+100H=10000H+0100H=10100H(2 2)MOV AX,MOV AX,VAL VAL 直接寻址方式,直接寻址方式,10030H10030H 物理地址物理地址DS10H+VAL=10000H+0030H=10030HDS
5、10H+VAL=10000H+0030H=10030H (3 3)MOV AX,MOV AX,BXBX 寄存器间接寻址,寄存器间接寻址,10100H10100H 物理地址物理地址DS10H+BX=10000H+0100H=10100H DS10H+BX=10000H+0100H=10100H (4 4)MOV AX,MOV AX,ES:BX ES:BX 寄存器间接寻址,寄存器间接寻址,20100H20100H 物理地址物理地址ES10H+BX=20000H+0100H=20100H ES10H+BX=20000H+0100H=20100H (5 5)MOV AX,MOV AX,SISI 寄存器
6、间接寻址,寄存器间接寻址,100A0H100A0H物理地址物理地址=DS10H+SI=10000H+00A0H=100A0H=DS10H+SI=10000H+00A0H=100A0H2021/6/42021/6/43 3(6 6)MOV AX,MOV AX,BX+10H BX+10H 寄存器相对寻址,寄存器相对寻址,10110H10110H物理地址物理地址=DS10H+BX+10H=10000H+0100H+10H=10110H=DS10H+BX+10H=10000H+0100H+10H=10110H(7 7)MOV AX,MOV AX,BPBP 寄存器间接寻址,寄存器间接寻址,35200H3
7、5200H物理地址物理地址=SS10H+BP=35000H+0200H=35200H=SS10H+BP=35000H+0200H=35200H(8 8)MOV AX,MOV AX,VALBPSIVALBPSI相对基址变址寻址,相对基址变址寻址,352D0H352D0H物理地址物理地址=SS10H+BP+SI+VAL=SS10H+BP+SI+VAL =35000H+0200H+00A0H+0030H=352D0H =35000H+0200H+00A0H+0030H=352D0H(9 9)MOV AX,MOV AX,VALBXDIVALBXDI 相对基址变址寻址,相对基址变址寻址,10154H10
8、154H物理地址物理地址=DS10H+BX+DI+VAL=DS10H+BX+DI+VAL =10000H+0100H+0024H+0030H=10154H =10000H+0100H+0024H+0030H=10154H(1010)MOV AX,MOV AX,BPDIBPDI基址变址寻址,基址变址寻址,35224H35224H物理地址物理地址=SS10H+BP+DI=SS10H+BP+DI =35000H+0200H+0024H=35224H =35000H+0200H+0024H=35224H2021/6/42021/6/44 46 6(1 1)MOVMOVDL,DL,AXAX 错,寄存器寻
9、址方式中,目的操作数与源操作数长度必须一致错,寄存器寻址方式中,目的操作数与源操作数长度必须一致(2 2)MOV MOV 8650H,8650H,AX AX 错,目的操作数不可以是立即数错,目的操作数不可以是立即数(3 3)MOVMOV DS,DS,0200H0200H 错,错,MOVMOV指令不允许将立即数传入段寄存器指令不允许将立即数传入段寄存器(4 4)MOVMOV BX,BX,1200H1200H 错错, MOV, MOV指令的两个操作数不能同时为存储器指令的两个操作数不能同时为存储器(5 5)MOVMOV IP,IP,0FFH0FFH 错错, IP, IP不能作为不能作为MOVMOV
10、指令的目的操作数指令的目的操作数(6 6)MOVMOV BX+SI+3,BX+SI+3,IPIP 错错, IP, IP不能作为不能作为MOVMOV指令的源操作数指令的源操作数(7 7)MOVMOV AX,AX,BXBPBXBP 错,错,BXBX与与BPBP不可以同时出现在源操作数当中不可以同时出现在源操作数当中(8 8)MOVMOV AL,AL,ES:BP ES:BP 对对2021/6/42021/6/45 5(9 9)MOVMOV DL,DL,SIDISIDI 错,错,SISI与与DIDI是两个变址寄存器,不可以同时出现在源操作数中。是两个变址寄存器,不可以同时出现在源操作数中。(1010)
11、MOVMOV AX, AX,OFFSET 0A20HOFFSET 0A20H 错,错,OFFSETOFFSET后面跟的应该是符号地址,再把符号地址的值作为后面跟的应该是符号地址,再把符号地址的值作为操作数。操作数。(1111)MOVMOV AL, AL,OFFSET TABLEOFFSET TABLE 错,错,TABLETABLE的偏移地址是的偏移地址是1616位,目的与源长度不一致位,目的与源长度不一致(1212)XCHGXCHGAL,AL,50H50H 错,交换指令可以在寄存器之间,寄存器和存储器之间进行,不错,交换指令可以在寄存器之间,寄存器和存储器之间进行,不可以是立即数。可以是立即数
12、。(1313)ININBL,BL,05H05H 错错, BL, BL不能作为不能作为ININ指令的目的操作数指令的目的操作数, ,只能用只能用ALAL或或AXAX(1414)OUTOUT AL,AL,0FFEH0FFEH 错,端口地址错,端口地址0FFEHFFH, 0FFEHFFH, 应用应用DXDX间接寻址间接寻址, , 同时源操作数和目同时源操作数和目标操作数的位置颠倒了标操作数的位置颠倒了, ,应改为应改为OUT DX, ALOUT DX, AL。2021/6/42021/6/46 68. SS=1050H, SP=0100H, AX=4860H, BX=1287H8. SS=1050H
13、, SP=0100H, AX=4860H, BX=1287H48H48H60H60H1050H:00FEH1050H:00FEHSPSP(a)(a)执行执行PUSH AXPUSH AX后后1050H:00FCH1050H:00FCH48H48H60H60H12H12H87H87HSPSP(b)(b)执行执行PUSH BXPUSH BX后后1050H:00FEH1050H:00FEH87H87H12H12H60H60H48H48HSPSP(c)(c)执行执行POP BXPOP BX后后1050H:0100H1050H:0100H87H87H12H12H60H60H48H48HSPSP(d)(d)
14、执行执行POP AXPOP AX后后2021/6/42021/6/47 710.10.ARRAY ARRAY DB DB NEWNEWDB 7 DUPDB 7 DUP(?)(?) SUM SUM DW 0 DW 0 AVERAGEAVERAGEDB 0 DB 0 (1 1)MOVMOV CX,CX,07H 07H MOVMOV BX,BX,00H00H NEXT NEXT: MOVMOV AL,AL,ARRAYBXARRAYBX ADDADDALAL,5 5 DAADAA MOVMOV NEWBXNEWBX,ALAL INCINCBXBX LOOPLOOP NEXTNEXTHLTHLT2021
15、/6/42021/6/48 8(2 2) MOVMOV CX,CX,06H 06H MOVMOV BXBX, 01H01HMOVMOV AH,AH,00H00H MOV MOV ALAL,ARRAYARRAY L1: L1: ADD AL ADD AL,ARRAYBXARRAYBX DAADAA ADCADCAH,AH,00H00H; ;将进位加到将进位加到AHAH中中 INC INCBXBX LOOP L1LOOP L1MOVMOV SUM,SUM, AXAX2021/6/42021/6/49 9(3 3)MOVMOV DX,DX,SUMSUM; DX=0H(BCD; DX=0H(BCD码码
16、) )MOVMOV BL,BL,07H07HMOVMOV AX,AX,DXDX; ; 取千位、百位数取千位、百位数ANDANDAL,AL,0F0H0F0HMOVMOV CL,CL,04H04HROLROLAL,AL,CLCL; AX=00H; AX=00HAADAAD; ALAH10; ALAH10AL, AH00 AL, AH00 DIVDIVBLBL;十位商在;十位商在ALAL中,余数在中,余数在AHAH中中MOVMOV AVERAGE+1, ALAVERAGE+1, AL;存平均成绩十位;存平均成绩十位MOVMOV AL,AL,DLDL;取个位和数;取个位和数ANDANDAL,AL,0F
17、H0FHAADAAD; ALAH10 ALAH10AL, AH00AL, AH00 DIVDIVBLBL;个位商在;个位商在ALAL中,余数在中,余数在AHAH中中MOVMOV AVERAGE,AVERAGE,ALAL;存平均成绩个位;存平均成绩个位MOVMOV AVERAGE+2, AHAVERAGE+2, AH; ; 存余数存余数2021/6/42021/6/4101011.AX=2508H11.AX=2508H,BX=0F36HBX=0F36H,CX=0004HCX=0004H,DX=1864HDX=1864H(1 1)ANDAND AH,AH,CLCLAH=04HAH=04H,CF=0
18、CF=0;(;(0010 0101B0010 0101B与与0000 0100B0000 0100B)(2 2)ORORBL,BL,30H30HBL=36HBL=36H,CF=0CF=0;(;(0011 0110B0011 0110B或或0011 0000B0011 0000B) (3 3)NOTNOT AXAXAX=DAF7HAX=DAF7H,CFCF无影响;(无影响;(0010 0101 0000 1000B0010 0101 0000 1000B取反后取反后1101 1010 1111 0111B1101 1010 1111 0111B) (4 4)XORXOR CX,CX,0FFF0H
19、0FFF0HCX=FFF4HCX=FFF4H,CF=0CF=0;(;(0000 0000 0000 0100B0000 0000 0000 0100B和和1111 1111 1111 0000B1111 1111 1111 0000B异或后异或后1111 1111 1111 0100B1111 1111 1111 0100B) (5 5)TESTTEST DH, DH,0FH0FHTESTTEST操作并不修改结果,操作并不修改结果,CF=0CF=0; 2021/6/42021/6/41111(6 6)CMPCMP CX,CX,00H00HCMPCMP操作并不修改结果,操作并不修改结果,CF=0
20、CF=0;(7 7)SHRSHR DX,DX,CLCLDX=0186HDX=0186H,CF=0CF=0;(8 8)SARSARAL,AL,1 1AH=04HAH=04H,CF=0CF=0;(9 9)SHLSHLBH,BH,CLCLBH=F0HBH=F0H,CF=0CF=0;(1010)SALSAL AX,AX,1 1AX=4A10HAX=4A10H,CF=0CF=0;(;( 0010 0101 0000 1000B 0010 0101 0000 1000B 左移左移)(1111)RCLRCL BX,BX,1 1若程序执行之前若程序执行之前CF=0CF=0,BX=1E6CHBX=1E6CH,C
21、F=0CF=0; 若程序执行之前若程序执行之前CF=1CF=1,BX=1E6DHBX=1E6DH,CF=0CF=0。(1212)RORROR DX, DX,CLCLDX=4186HDX=4186H,CF=0CF=0。 2021/6/42021/6/4121212.DATA12.DATASEGMENTSEGMENT STRING DB The personal computer & TVSTRING DB The personal computer & TV DATA ENDS DATA ENDSEDATA SEGMENTEDATA SEGMENTGET_CHARGET_CHAR DBDB26D
22、UP(?)26DUP(?) NEW_STRNEW_STRDBDBThe computerThe computer EDATA ENDS EDATA ENDS (1) (1)MOV MOV SI,SI,OFFSET STRINGOFFSET STRING MOV MOV DI,DI,OFFSET GET_CHAROFFSET GET_CHAR MOV MOV CX, CX, 001AH001AH CLDCLD REPREPMOVSBMOVSB2021/6/42021/6/41313 (2) (2) MOVMOV SI,SI,OFFSET STRINGOFFSET STRING MOVMOV DI
23、,DI,OFFSET NEW_STROFFSET NEW_STR MOV CX,MOV CX,001AH001AH CLDCLD REPZREPZ CMPSBCMPSB;DS:SI-ES:DIDS:SI-ES:DI JNEJNECLR_ALCLR_AL MOVMOV AL,AL,1 1 JMP SET_BLJMP SET_BL CLR_AL: CLR_AL:MOVMOV AL,AL,0 0 SET_BL: SET_BL:MOVMOV BL,BL,001AH001AHSUBSUBBL,BL,CLCLHLTHLT2021/6/42021/6/41414(3 3)MOVMOV DI,DI,OFFSE
24、TOFFSETSTRINGSTRING MOVMOV CX,CX,001AH001AH MOVMOV AL,AL,& CLDCLDL1: L1: SCASBSCASB;AL-ES:DIAL-ES:DI JZ FINDJZ FINDNEXT:NEXT:LOOPLOOP L1L1HLTHLTFIND: FIND: MOV BL, MOV BL, MOV DI-1,MOV DI-1, BLBL; ; 用空格替换用空格替换& & JMPJMPNEXTNEXT2021/6/42021/6/41515(4 4)MOV MOV SI,SI,OFFSET STRINGOFFSET STRING;数据段,源串;
25、数据段,源串 MOV MOV DI,DI,OFFSET CAPSOFFSET CAPS;附加段,大写字符;附加段,大写字符 MOV MOV BX,BX,OFFSET CHARTOFFSET CHART;附加段,其它字符;附加段,其它字符 MOV MOV CX,CX,001AH001AH CLDCLD L1: L1: LODSB LODSB ;ALDS:SIALDS:SIMOVMOVSI-1,SI-1,00H00H; ; 取出字符后该单元清零取出字符后该单元清零 CMPCMPAL,AL,AA JBJBOTHEROTHER CMPCMPAL,AL,ZZJAJAOTHEROTHERSTOSBSTOS
26、B; ; 存大写字符存大写字符JMPJMPL2L2 OTHER: OTHER: XCHGXCHG BX,BX,DIDI; ; 存其它字符存其它字符 STOSBSTOSB XCHG BX,XCHG BX,DIDI L2: L2: LOOPLOOPL1L1 HLT HLT 2021/6/42021/6/416161414.(1)JMP.(1)JMP PROG_NPROG_N 段内直接近转移,目的地址为段内直接近转移,目的地址为1200H:0278H(1200H:0278H(或或12278H)12278H) (2)JMP(2)JMPBXBX 段内寄存器间接转移,目的地址为段内寄存器间接转移,目的地址
27、为1200H:0300H(1200H:0300H(或或12300H)12300H) (3)JMP(3)JMPBXBX 物理地址物理地址DS10H+BX=2000H10H+0300H=20300HDS10H+BX=2000H10H+0300H=20300H (20300H)=4800H (20300H)=4800HIPIP 段内存储器间接转移,目的地址为段内存储器间接转移,目的地址为1200H:4800H(1200H:4800H(或或16800H)16800H) (4)JMP(4)JMPFARFARPROG_FPROG_F 段间立接转移,目的地址为段间立接转移,目的地址为3400H:0ABCH(
28、3400H:0ABCH(或或34ABCH)34ABCH) (5)JMP(5)JMPDWORDDWORDPTRBXPTRBX 物理地址物理地址DS10H+BX=2000H10H+0300H=20300HDS10H+BX=2000H10H+0300H=20300H (20300H)=4800H (20300H)=4800HIPIP, ,(20302H)=00FFH(20302H)=00FFHCSCS 段间存储器间接转移,目的地址为段间存储器间接转移,目的地址为00FFH:4800H(00FFH:4800H(或或057F0H)057F0H)2021/6/42021/6/41717JMPJMP改为改为
29、改为改为CALLCALL后,目的地址与后,目的地址与后,目的地址与后,目的地址与JMPJMP相同。相同。相同。相同。(1)CALL(1)CALLPROG_NPROG_N段内直接调用,段内直接调用,3 3字节指令,字节指令,0103H0103H入栈入栈(2)CALL(2)CALLBXBX段内寄存器间接调用,段内寄存器间接调用,2 2字节指令,字节指令,0102H0102H入栈入栈(3)CALL(3)CALLBXBX段内存储器间接调用,段内存储器间接调用,2 2字节指令,字节指令,0102H0102H入栈入栈(4)CALL(4)CALLFARFARPROG_FPROG_F段间直接调用,段间直接调用
30、,5 5字节指令,字节指令,1200H1200H和和0105H0105H分别入栈分别入栈(5)CALL(5)CALLDWORDDWORDPTRBXPTRBX段间间接调用,段间间接调用,2 2字节指令,字节指令,1200H1200H和和0102H0102H分别入栈分别入栈2021/6/42021/6/4181815.15.(1 1)LOOPLOOPNEXTNEXT (2 2)LOOPELOOPE NEXTNEXT (3 3)LOOPNELOOPNENEXTNEXTSTART:START:MOVMOV AX,AX,01H01HMOVMOV BX,BX,02H02HMOVMOV DX,DX,03H0
31、3HMOVMOV CX,CX,04H04HNEXT:NEXT:INCINCAXAXADDADDBX,BX,AXAXSHRSHRDX,DX,1 1( () ) 程序运行前程序运行前 DX=00000011B DX=00000011B (1 1)AX=05H BX=10H CX=00H DX=00HAX=05H BX=10H CX=00H DX=00H (2 2)AX=02H BX=04H CX=03H DX=01HAX=02H BX=04H CX=03H DX=01H (3 3)AX=03H BX=07H CX=02H DX=00HAX=03H BX=07H CX=02H DX=00H2021/
32、6/42021/6/4191918.(1 1)中断类型号为)中断类型号为0040H/4=10H0040H/4=10H(2 2)中断服务程序的段地址为)中断服务程序的段地址为D169HD169H,偏移地址为,偏移地址为240BH240BH,即即D169H:240BHD169H:240BH,物理地址为,物理地址为D169H10HD169H10H240BH240BHD3A9BHD3A9BH0BH0BH24H24H69H69HD1HD1H0000H:0040H0000H:0040H0000H:0042H0000H:0042H中断向量表中断向量表2021/6/42021/6/42020部分资料从网络收集整理而来,供大家参考,感谢您的关注!