1、1D000H1D001H1D002H1D003H AX8FF10H8FF11H8FF12H8FF13H3.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) 寄存器相对寻址 20000H0100H+0AH2010AH(10)
2、寄存器相对寻址 20150H(11) 基址变址寻址 201A0H(12) 相对基址变址寻址 201F0H3.9(1) MOV AX, BX+12MOV ZERO, AX(2) MOV AX, ARRAYBX3.10(1) 1234H(2) 0032H3.111E00H3.13 SP 57H 0FFAAEH 80H 0FFAAFHSP 0FFAB0H (1)初始 (2)8057H入栈SP 79H 0FFACH 79H 0FFACH 0FH 0FFADH 0FH 0FFADH 57H 0FFAEH SP 57H 0FFAEH 80H 0FFAFH 80H 0FFAFH (3)0F79H入栈 (4)
3、0F79H出栈3.15 62A0H 62A0H 62A0H 62A0H+1234H +4321H +CFA0H +9D60H 74D4H A5C1H 3240H (1)0000HSF 0 1 0 0ZF 0 0 0 1CF 0 0 1 1OF 0 1 0 03.17(1) MOV AX, Z SUB AX, XADD AX, WMOV Z, AX(2) ADD X, 6ADD R,9MOV AX, WSUB AX, R(3) MOV AX, W IMUL XADD Y, 6MOV BX, YIDIV BXMOV R, DX(4) MOV BX, W SUB BX, X ;(BX)=W-XMOV
4、 AX, YMOV CX, 5IMUL CX ;(DX,AX)=Y5MOV CX AXMOV AX, BX ;BX扩展到EAX(32位)CWD ;被除数扩展到64位IDIV CX ;除数Y限制为字(16位)SAL AX,1MOV Z, AX ;可以认为AX能存储下结果3.19 程序 CF SF ZF 0F MOV AX, 0 0000H - DEC AX FFFFH 1 0 1 ADD AX, 7FFFH 7FFFH ADD AX, 2 8000H NOT AX SUB AX, 0FFFFH ADD AX, 8000H SUB AX, 1 AND AX, 58D1H 58D1H SAC AX,
5、 1 B1A2H SAR AX, 1 D8D1H NEG AX 272FH ROR AX, 1 9397H3.21 NOT AX NOT DX ADD AX, 1 ADC DX, 03.23 (1) BX=009AH (2) BX=0061H (3) BX=00FBH (4) BX=001CH (5) BX=0000H (6) BX=0001H3.25(1) +532 MOV AL, 35H (2) -492 MOV AL, CFHSAL AL, 1 SAL AL, 1结果为6AH106D 结果为9EH-98D(3) +532 MOV AL, 35H (4) -492 MOV AL, CFHS
6、AR AL, 1 SAR AL, 1结果为 1AH=26D 结果为 E7H=-24D3.27(1) DX=0000 0000 0101 1100B(2) DX=0000 0000 0001 0111B(3) DX=0000 0101 1100 1000B(4) DX=0000 0000 0111 0010B(5) DX=0001 0000 0001 0111B(6) DX=0000 0000 1100 1101B(7) DX=0000 0000 1011 1001B(8) DX=0000 0101 1100 1100B(9) DX=0000 0000 1101 1100B3.29(1) LEA
7、 SI, CONAME (2) LEA SI, CONAME (3) LEA SI, CONAME LEA DI, PRLINE ADD SI, 19 ADD SI, 2MOV CX, 20 LEA DI, PRLINE LODSWCLD ADD DI, 19REP MOVSB STD REP MOVSB(4) LEA DI, PRLINE (5) LEA DI, CONAMEADD DI, 5 MOV AL, 20HSTOSW MOV CX, 20CLDREPNE SCASBJNZ NO-FOUNDMOV BH, AL.NO-FOUND:3.31(1) CLD (2) LEA DI, STU
8、DENT_ADDRMOV CX, 132 MOV AL, MOV AL, 20H MOV CX, 9LEA DI, PRINT_LINE CLDREP STOSB REPNE SCASB 第一个在DI-1中 (3) LEA DI, STUDENT_ADDR+8 STD MOV AL, REPNE SCASBMOV CX,9 最后一个在DI-1中 (4) LEA DI, STUDENT_NAME (5) CLDMOV AL, 20H MOV CX, 30MOV CX, 30 LEA SI, STUDENT_NAMECLD LEA DI, PRINT_LINEREPE SCASB REP MOVS
9、BJNE NO-MATCH STDMOV CX, 30 MOV CX, 9LEA DI, STUDENT_NAME LEA SI, STUDENT_ADDR+8MOV AL, LEA DI, PRINT_LINE+131REP STOSB REP MOVSBNO-MATCH:HLT3.35 AX BX JB JNB JBE JNBE JL JNL JLE JNLE1F52H 88C9HFF82H007EH58BAH020EHFFC5HFF8BH09A0H1E97H8AEAHFC29HD367H32A6H3.37 MOV AL, STATUS TEST AL, 00101010B JZ ROUT
10、INE-4 ;当全为0时 JP ROUTINE-2 ;偶转移,当有2个1时(0的情况前一条已经跳转) CMP AL, 00101010B JZ ROUTINE-1 ;当为3个1时 JMP ROUTINE-3 ;剩余情况,1个1时。3.39(1) (2)0400H0A00H(3) (4) 0100H B200H 0A00H 0400H0100HB200H(5) (6) 0C00H(7) (8)(9) 0600H 1000H(1) LEA SI,CONAME LEA DI,PRLINE MOV CX,20 CLD(2) LEA SI,CONAME+19 LEA DI,PRLINE+19 STD(3
11、) LEA SI,CONAME+3 LODSB MOV AH,AL(4) LEA DI,PRLINE+5 STOSB MOV AL,AH(5) LEA DI,CONAME MOV AL,20H REPNZ SCASB JNZ NOFOUND MOV BH,20H*3.30 P112 LEA DI,STRING MOV CX,18 MOV AL,& DEC DI MOV DI,20H (1) LEA SI,PRINT_LINE MOV CX,132 REP LODSB(2) LEA DI,STUDENT_ADDR MOV CX,9_(3) LEA DI,STUDENT_ADDR+8(4) LEA
12、 SI,STUDENT_NAME MOV CX,30AGA: CMP AL,20H JZ NEXT JMP SHORT NEXT1NEXT: LOOP AGANEXT1: JNZ EXIT LEA DI,STUDENT_NAME* REP STOSBEXIT:(5) LEA SI,STUDENT_NAME LEA DI,PRINT_LINE LEA SI,STUDENT_ADDR+8 LEA DI,PRINT_LINE+1313.32 LEA SI,OLDS LEA DI,NEWS MOV CX,5 REPZ CMPSB JNZ NEW_LESS3.33(1) CMP DX,CX JA EXC
13、EED(2) CMP BX,AX JG EXCEED(3) CMP CX,0 JZ ZERO(4) CMP BX,AX JO OVERFLOW(5) CMP BX,AX JLE EQ_SMA(6) CMP DX,CX JBE EQ_SMA3.34(1) L1(2) L1(3) L2(4) L5(5) L5(1)JNB JBE JNL JLE(2)JNB JBE JNL JLE(3)JNB JNBE JL JLE(4)JNB JNBE JNL JNLE(5)JNB JNBE JNL JNLE(6)JB JBE JL JLE(7)JB JBE JL JLE(8)JNB JNBE JL JLE3.3
14、6 2P=q AX=1 2pq AX=2 MOV AL,STATUS NOT AL TEST AL,2AH JZ ROUTINE_1 TEST AL,0AH JZ ROUTINE_2 TEST AL,22H TEST AL,28H TEST AL,02H JZ ROUTINE_3 TEST AL,08H TEST AL,20H JMP ROUTINE_43.38(1) LOOP L20 AX=5 BX=10H DX=0 CX=0(2) LOOPE L20 AX=2 BX=4 DX=1 CX=3(3) LOOPNE L20 AX=3 BX=7 DX=0 CX=2第5章作业答案5.1datarea
15、 segment mess1 db Please input letter:,13,10,$ mess2 db Please input again:datarea endsprogram segmentmain proc far assume cs:program,ds:datareastart: push ds sub ax,ax push ax mov ax,datarea mov ds,ax lea dx,mess1 mov ah,09 int 21hinput: mov ah,07 cmp al,61h jb again cmp al,7Ah ja again sub al,20h
16、mov dl,al mov ah,02 jmp short exitagain: lea dx,mess2 jmp short inputexit: retmain endpprogram ends end start5.2 string db chinasdujlpprognam segmentprognam,ds:datarea,es:mov ax,datarea mov es,ax lea di,string mov ah,01 mov cx,11 cld repnz scasb jz find jmp inputfind: sub di,2 mov cx,3lop: mov dl,di
17、 inc di dec cx jz exit jmp short lopprognam ends5.3 mov ax,1234h mov cl,4 rol ax,cl and dl,0fh add dl,30h rol ax,cl mov ch,al and ch,0fh mov bl,al and bl,0fh add bl,30h and al,0fh add al,30h mov dh,al mov cl,ch add cl,30h mov dl,cl mov dl,bl mov dl,dh mov al,dh5.55.6 M db -3,-2,-1,-8,-5,0,-9,-23,-100,-52,-1,-19,-18,-3,32,-4,-6,-17,11,24 P db 20 dup(?) N db 20 dup(? mov dh,0 mov dl,0 mov di,20 mov bx,0 cmp Mbx,0 jl less inc dh mov ch,Mbx mov P,ch inc P jmp nextless: inc
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1