IBMPC汇编语言作业答案文档格式.docx
《IBMPC汇编语言作业答案文档格式.docx》由会员分享,可在线阅读,更多相关《IBMPC汇编语言作业答案文档格式.docx(70页珍藏版)》请在冰豆网上搜索。
![IBMPC汇编语言作业答案文档格式.docx](https://file1.bdocx.com/fileroot1/2023-1/31/45ca1c23-0225-4973-b35e-5c6e1c791eee/45ca1c23-0225-4973-b35e-5c6e1c791eee1.gif)
1D000H
1D001H
1D002H
1D003H
AX
8FF10H
8FF11H
8FF12H
8FF13H
3.7
(1)0626H+27H=064DH
(2)0626H+6BH=0691H
(3)0626H+0FFC6H=05ECH(注意符号扩展)
3.8
寻址方式物理地址
(1)立即数寻址无
(2)寄存器寻址无
(3)直接寻址20100H
(4)直接寻址20050H
(5)寄存器间接寻址20100H
(6)寄存器间接寻址21100H
(7)寄存器间接寻址15010H
(8)寄存器间接寻址200A0H
(9)寄存器相对寻址20000H+0100H+0AH=2010AH
(10)寄存器相对寻址20150H
(11)基址变址寻址201A0H
(12)相对基址变址寻址201F0H
3.9
(1)MOVAX,[BX+12]
MOVZERO,AX
(2)MOVAX,ARRAY[BX]
3.10
(1)1234H
(2)0032H
3.11
1E00H
3.13
SP57H0FFAAEH
80H0FFAAFH
SP0FFAB0H
(1)初始
(2)8057H入栈
SP
79H0FFACH79H0FFACH
0FH0FFADH0FH0FFADH
57H0FFAEHSP57H0FFAEH
80H0FFAFH80H0FFAFH
(3)0F79H入栈(4)0F79H出栈
3.15
62A0H62A0H62A0H62A0H
+1234H+4321H+CFA0H+9D60H
74D4HA5C1H3240H
(1)0000H
SF0100
ZF0001
CF0011
OF0100
3.17
(1)MOVAX,Z
SUBAX,X
ADDAX,W
MOVZ,AX
(2)ADDX,6
ADDR,9
MOVAX,W
SUBAX,R
(3)MOVAX,W
IMULX
ADDY,6
MOVBX,Y
IDIVBX
MOVR,DX
(4)MOVBX,W
SUBBX,X;
(BX)=W-X
MOVAX,Y
MOVCX,5
IMULCX;
(DX,AX)=Y×
5
MOVCXAX
MOVAX,BX;
BX扩展到EAX(32位)
CWD;
被除数扩展到64位
IDIVCX;
除数Y限制为字(16位)
SALAX,1
MOVZ,AX;
可以认为AX能存储下结果
3.19
程序
CF
SF
ZF
0F
MOVAX,0
0000H
----
DECAX
FFFFH
1
0
1
ADDAX,7FFFH
7FFFH
ADDAX,2
8000H
NOTAX
SUBAX,0FFFFH
ADDAX,8000H
SUBAX,1
ANDAX,58D1H
58D1H
SACAX,1
B1A2H
SARAX,1
D8D1H
NEGAX
272FH
RORAX,1
9397H
3.21
NOTAX
NOTDX
ADDAX,1
ADCDX,0
3.23
(1)BX=009AH
(2)BX=0061H(3)BX=00FBH(4)BX=001CH(5)BX=0000H(6)BX=0001H
3.25
(1)+53×
2MOVAL,35H
(2)-49×
2MOVAL,CFH
SALAL,1SALAL,1
结果为6AH=106D结果为9EH=-98D
(3)+53÷
2MOVAL,35H(4)-49÷
2MOVAL,CFH
SARAL,1SARAL,1
结果为1AH=26D结果为E7H=-24D
3.27
(1)DX=0000000001011100B
(2)DX=0000000000010111B
(3)DX=0000010111001000B
(4)DX=0000000001110010B
(5)DX=0001000000010111B
(6)DX=0000000011001101B
(7)DX=0000000010111001B
(8)DX=0000010111001100B
(9)DX=0000000011011100B
3.29
(1)LEASI,CONAME
(2)LEASI,CONAME(3)LEASI,CONAME
LEADI,PRLINEADDSI,19ADDSI,2
MOVCX,20LEADI,PRLINELODSW
CLDADDDI,19
REPMOVSBSTD
REPMOVSB
(4)LEADI,PRLINE(5)LEADI,CONAME
ADDDI,5MOVAL,20H
STOSWMOVCX,20
CLD
REPNESCASB
JNZNO-FOUND
MOVBH,AL
…….
NO-FOUND:
3.31
(1)CLD
(2)LEADI,STUDENT_ADDR
MOVCX,132MOVAL,‘-’
MOVAL,20HMOVCX,9
LEADI,PRINT_LINECLD
REPSTOSBREPNESCASB
第一个‘—’在DI-1中
(3)LEADI,STUDENT_ADDR+8STD
MOVAL,‘-’REPNESCASB
MOVCX,9最后一个‘-’在DI-1中
(4)LEADI,STUDENT_NAME(5)CLD
MOVAL,20HMOVCX,30
MOVCX,30LEASI,STUDENT_NAME
CLDLEADI,PRINT_LINE
REPESCASBREPMOVSB
JNENO-MATCHSTD
MOVCX,30MOVCX,9
LEADI,STUDENT_NAMELEASI,STUDENT_ADDR+8
MOVAL,‘﹡’LEADI,PRINT_LINE+131
REPSTOSBREPMOVSB
NO-MATCH:
HLT
3.35
AX
BX
JB
JNB
JBE
JNBE
JL
JNL
JLE
JNLE
1F52H
×
√
√
88C9H
FF82H
007EH
58BAH
020EH
FFC5H
FF8BH
09A0H
1E97H
8AEAH
FC29H
D367H
32A6H
3.37
MOVAL,STATUS
TESTAL,00101010B
JZROUTINE-4;
当全为0时
JPROUTINE-2;
偶转移,当有2个1时(0的情况前一条已经跳转)
CMPAL,00101010B
JZROUTINE-1;
当为3个1时
JMPROUTINE-3;
剩余情况,1个1时。
3.39
(1)
(2)
0400H
0A00H
(3)(4)
0100H
B200H
0A00H
0400H
0100H
B200H
(5)(6)
0C00H
(7)(8)
(9)
0600H
1000H
(1)LEASI,CONAME
LEADI,PRLINE
MOVCX,20
CLD
(2)LEASI,CONAME+19
LEADI,PRLINE+19
STD
(3)LEASI,CONAME+3
LODSB
MOVAH,AL
(4)LEADI,PRLINE+5
STOSB
MOVAL,AH
(5)LEADI,CONAME
MOVAL,20H
REPNZSCASB
JNZNOFOUND
MOVBH,20H
************************************
3.30P112
LEADI,STRING
MOVCX,18
MOVAL,'
&
'
DECDI
MOV[DI],20H
(1)LEASI,PRINT_LINE
MOVCX,132
REPLODSB
(2)LEADI,STUDENT_ADDR
MOVCX,9
_'
(3)LEADI,STUDENT_ADDR+8
(4)LEASI,STUDENT_NAME
MOVCX,30
AGA:
CMPAL,20H
JZNEXT
JMPSHORTNEXT1
NEXT:
LOOPAGA
NEXT1:
JNZEXIT
LEADI,STUDENT_NAME
*'
REPSTOSB
EXIT:
(5)LEASI,STUDENT_NAME
LEADI,PRINT_LINE
LEASI,STUDENT_ADDR+8
LEADI,PRINT_LINE+131
3.32
LEASI,OLDS
LEADI,NEWS
MOVCX,5
REPZCMPSB
JNZNEW_LESS
3.33
(1)CMPDX,CX
JAEXCEED
(2)CMPBX,AX
JGEXCEED
(3)CMPCX,0
JZZERO
(4)CMPBX,AX
JOOVERFLOW
(5)CMPBX,AX
JLEEQ_SMA
(6)CMPDX,CX
JBEEQ_SMA
3.34
(1)L1
(2)L1
(3)L2
(4)L5
(5)L5
(1)JNBJBEJNLJLE
(2)JNBJBEJNLJLE
(3)JNBJNBEJLJLE
(4)JNBJNBEJNLJNLE
(5)JNBJNBEJNLJNLE
(6)JBJBEJLJLE
(7)JBJBEJLJLE
(8)JNBJNBEJLJLE
3.36
2P>
=qAX=1
2p<
qAX=2
MOVAL,STATUS
NOTAL
TESTAL,2AH
JZROUTINE_1
TESTAL,0AH
JZROUTINE_2
TESTAL,22H
TESTAL,28H
TESTAL,02H
JZROUTINE_3
TESTAL,08H
TESTAL,20H
JMPROUTINE_4
3.38
(1)LOOPL20
AX=5BX=10HDX=0CX=0
(2)LOOPEL20
AX=2BX=4DX=1CX=3
(3)LOOPNEL20
AX=3BX=7DX=0CX=2
第5章作业答案
5.1
datareasegment
mess1db'
Pleaseinputletter:
13,10,'
$'
mess2db'
Pleaseinputagain:
datareaends
programsegment
mainprocfar
assumecs:
program,ds:
datarea
start:
pushds
subax,ax
pushax
movax,datarea
movds,ax
leadx,mess1
movah,09
int21h
input:
movah,07
cmpal,61h
jbagain
cmpal,7Ah
jaagain
subal,20h
movdl,al
movah,02
jmpshortexit
again:
leadx,mess2
jmpshortinput
exit:
ret
mainendp
programends
endstart
5.2
stringdb'
chinasdujlp'
prognamsegment
prognam,ds:
datarea,es:
movax,datarea
moves,ax
leadi,string
movah,01
movcx,11
cld
repnzscasb
jzfind
jmpinput
find:
subdi,2
movcx,3
lop:
movdl,[di]
incdi
deccx
jzexit
jmpshortlop
prognamends
5.3
movax,1234h
movcl,4
rolax,cl
anddl,0fh
adddl,30h
rolax,cl
movch,al
andch,0fh
movbl,al
andbl,0fh
addbl,30h
andal,0fh
addal,30h
movdh,al
movcl,ch
addcl,30h
movdl,cl
movdl,bl
movdl,dh
moval,dh
5.5
5.6
Mdb-3,-2,-1,-8,-5,0,-9,-23,-100,-52,-1,-19,-18,-3,32,-4,-6,-17,11,24
Pdb20dup(?
)
Ndb20dup(?
movdh,0
movdl,0
movdi,20
movbx,0
cmpM[bx],0
jlless
incdh
movch,M[bx]
movP,ch
incP
jmpnext
less:
inc