1、IBM-PC 汇编语言作业答案第三章作业答案3.1寻址方式 有效地址(EA)(1) 立即寻址 无(2) 直接寻址 7237H(3) BX 寄存器寻址 无(4) BX 寄存器间接寻址 637DH(5) BX 寄存器相对寻址 0D5B4H(6) 基址变址寻址 8E18H(7) 相对基址变址寻址 004FH3.2(1) ADD DX, BX(2) ADD AL, BXSI(3) ADD BX+OB2H, CX(4) ADD WORD PTR0524H, 2A59H(5) ADD AL,0B5H3.3(1) LEA BX, BLOCK+(6-1)*2MOV DX, BX(2) LEA BX, BLOC
2、KMOV DX, BX+10(3) MOV SI, 10LEA BX, BLOCKMOV DX, BXSI3.4(1) 1200H(2) 0100H(3) 4C2AH(4) 3412H(5) 4C2AH(6) 7856H(7) 65B7H3.52(1) EA=(IP)+D=7CD9H(2) 物理地址=16 DS+(BX)=224A0H IP=0600H(3) 物理地址=16 DS+(BX)+D=275B9H IP=098AH3.6MOV BX, 2000HLDS SI, BXMOV AX, SIAX3.7(1) 0626H+27H=064DH(2) 0626H+6BH=0691H(3) 062
3、6H+0FFC6H=05ECH (注意符号扩展)3.8寻址方式 物理地址(1) 立即数寻址 无(2) 寄存器寻址 无(3) 直接寻址 20100H(4) 直接寻址 20050H(5) 寄存器间接寻址 20100H(6) 寄存器间接寻址 21100H(7) 寄存器间接寻址 15010H(8) 寄存器间接寻址 200A0H(9) 寄存器相对寻址 20000H0100H+0AH2010AH(10) 寄存器相对寻址 20150H(11) 基址变址寻址 201A0H(12) 相对基址变址寻址 201F0H3.910 FF00801D000H1D001H1D002H1D003H8FF10H8FF11H8F
4、F12H8FF13H3(1) MOV AX, BX+12MOV ZERO, AX(2) MOV AX, ARRAYBXMOV ZERO, AX3.10(1) 1234H(2) 0032H3.111E00H3.13SP 57H 0FFAAEH80H 0FFAAFHSP 0FFAB0H (1)初始 (2)8057H 入栈SP 79H 0FFACH 79H 0FFACH0FH 0FFADH 0FH 0FFADH57H 0FFAEH SP 57H 0FFAEH80H 0FFAFH 80H 0FFAFH(3)0F79H 入栈 (4)0F79H 出栈3.1562A0H 62A0H 62A0H 62A0H+
5、1234H +4321H +CFA0H +9D60H74D4H 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, AX4(2) ADD X, 6ADD R,9MOV AX, WSUB AX, XSUB AX, RMOV Z, AX(3) MOV AX, WIMUL XADD Y, 6MOV BX, YIDIV BXMOV Z, AXMOV R, DX(4) MOV BX, WSUB BX, X ;(BX)=W-XMOV AX, YMOV C
6、X, 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程序 AX CF SF ZF 0FMOV AX, 0 0000H - - - -DEC AX FFFFH - 1 0 1ADD AX, 7FFFH 7FFFH 1 0 0 0ADD AX, 2 8000H 0 1 0 1NOT AX 7FFFH 0 1 0 1SUB AX, 0FFFFH 8000H 1 1 0 1ADD A
7、X, 8000H 0000H 1 0 1 1SUB AX, 1 FFFFH 1 1 0 0AND AX, 58D1H 58D1H 0 0 0 0SAC AX, 1 B1A2H 0 1 0 1SAR AX, 1 D8D1H 0 1 0 0NEG AX 272FH 1 0 0 0ROR AX, 1 9397H 1 1 0 13.21NOT AXNOT DX5ADD AX, 1ADC 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, 35
8、H (2) -492 MOV AL, CFHSAL AL, 1 SAL AL, 1结果为 6AH106D 结果为 9EH-98D(3) +532 MOV AL, 35H (4) -492 MOV AL, CFHSAR 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 0
9、000 1100 1101B(7) DX=0000 0000 1011 1001B(8) DX=0000 0101 1100 1100B(9) DX=0000 0000 1101 1100B3.29(1) LEA 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 STDREP MOVSB(4) LEA DI, PRLINE (5) LEA DI, CONAMEADD D
10、I, 5 MOV AL, 20HSTOSW MOV CX, 20CLDREPNE SCASBJNZ NO-FOUNDMOV BH, AL.NO-FOUND:3.31(1) CLD (2) LEA DI, STUDENT_ADDRMOV CX, 132 MOV AL, MOV AL, 20H MOV CX, 9LEA DI, PRINT_LINE CLD6REP STOSB REPNE SCASB第一个在 DI-1 中(3) LEA DI, STUDENT_ADDR+8 STD MOV AL, REPNE SCASBMOV CX,9 最后一个在 DI-1 中 (4) LEA DI, STUDEN
11、T_NAME (5) CLDMOV AL, 20H MOV CX, 30MOV CX, 30 LEA SI, STUDENT_NAMECLD LEA DI, PRINT_LINEREPE SCASB REP MOVSBJNE 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.35AX BX JB JNB JBE JNBE JL JNL JLE JNLE1F52H 1F52
12、H 88C9H 88C9H FF82H 007EH 58BAH 020EH FFC5H FF8BH 09A0H 1E97H 8AEAH FC29H D367H 32A6H 3.37MOV AL, STATUSTEST AL, 00101010BJZ ROUTINE-4 ;当全为 0 时JP ROUTINE-2 ;偶转移,当有 2 个 1 时(0 的情况前一条已经跳转)CMP AL, 00101010BJZ ROUTINE-1 ;当为 3 个 1 时JMP ROUTINE-3 ;剩余情况,1 个 1 时。3.39(1) (2)(3) (4) 0400H0A00H0400H70100HB200H0
13、A00H0400H(5) (6)(7) (8)(9) 0100H0C00H0600H1000H3.29(1) LEA SI,CONAMELEA DI,PRLINEMOV CX,20CLDREP MOVSB(2) LEA SI,CONAME+190100HB200H0A00H0400H0100H0C00H0A00H0400H0100H0C00H0A00H0400H0100H0C00H0A00H0400H0100H0C00H0A00H0400H8LEA DI,PRLINE+19MOV CX,20STDREP MOVSB(3) LEA SI,CONAME+3STDLODSBMOV AH,ALLODS
14、B(4) LEA DI,PRLINE+5CLDSTOSBMOV AL,AHSTOSB(5) LEA DI,CONAMEMOV CX,20MOV AL,20HCLDREPNZ SCASBJNZ NOFOUNDMOV BH,20H*3.30 P112LEA DI,STRINGMOV CX,18MOV AL,;EXC9_8.ASM;2002.12.1;data segmentinput label bytemax db 101act db ?inp db 101 dup(0)buffer db 100 dup(0),$data ends;code segmentassume cs:code,ds:d
15、ata,es:datamain proc farpush dsmov ax,0push axmov ax,datamov ds,axmov es,axmov bx,0goon:lea dx,inputmov ah,0ahint 21h call crlfcmp act,blja nextmov al,actcbwmov si,axdec sicmp inpsi,$je exitjmp goonnext:mov bl,actcall stormov al,actcbw mov si,axdec sicmp inpsi,$jne goonexit:call displayretmain endp;
16、stor proc nearlea si,inplea di,buffermov cx,bxrep movsbretstor endp;display proc nearlea dx,buffermov ah,09hint 21hretdisplay endp;crlf proc nearmov dl,0dh27mov ah,02hint 21hmov dl,0ahmov ah,02hint 21hretcrlf endp;code endsend main第 10 章作业答案10.18;EXC10_18.ASM;2002.12.1;STACK SEGMENT DB 64 DUP(STACK.
17、)STACK ENDS;DATA SEGMENT PARA DATAMENU DB 13,10DB ,0DAH,20 DUP(0C4H),0BFH,13,10DB ,0B3H,A SONG FOR CHINA ,0B3H,13,10DB ,0B3H,20 DUP( ),0B3H,13,10DB ,0B3H,B BLUE DUONAO RIVER,0B3H,13,10DB ,0B3H,20 DUP( ),0B3H,13,10DB ,0B3H,C HONG HE GU ,0B3H,13,10DB ,0C0H,20 DUP(0C4H),0D9H,13,10,$DFREQA DW 262,330,39
18、2,392,440,392DW 330,262,392,392,392,330,262DW 196,262DW 330,262,392,392,392,330,262DW 196,262,196,262,196,262,262,-1DTIMEA DW 25,25,25,25,50,50DW 25,25,18,18,18,50,50DW 100,50DW 25,25,25,25,50,50DW 7 DUP(50)DFREQB DW 262,262,330,392,523DW 294,294,349,440,440DW 349,392,623,623,523,330,330,294,440,392
19、,262,-1DTIMEB DW 25,25,25,25,150DW 25,25,25,25,100DW 25,25,75,25,25,25,50,25,50,25,50DFREQC DW 196,262,330,330,294,262,294,262,262DW 196,262,330,330,330,392,349,330,294DW 392,349,330,330,294,262,294,330,392,349,349DW 220,220,196,247,262,294,330,294,262,-1DTIMEC DW 25,25,50,25,25,50,25,25,25,25,100DW
20、 25,25,50,25,25,50,25,25,150DW 25,25,50,25,25,50,25,25,25,25,100DW 25,25,50,25,25,50,25,25,150DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATA,SS:STACKPUSH DSSUB AX,AXPUSH AXMAIN PROC FARMOV AX,DATAMOV DS,AXMOV AH,09HLEA DX,MENUINT 21HINPUT:MOV AH,01H28INT 21HCMP AL,0JE EXITCMP AL,AJNE B0LEA SI,DFREQALEA
21、 BP,DTIMEACALL MUSICJMP INPUTB0:CMP AL,BJNE C0LEA SI,DFREQBLEA BP,DTIMEBCALL MUSICJMP INPUTC0:CMP AL,CJNE INPUTLEA SI,DFREQCLEA BP,DTIMECCALL MUSICJMP INPUTEXIT:MOV CX,4C00HINT 21HMAIN ENDP;MUSIC PROC NEARFREQ:MOV DI,SICMP DI,-1JE ENDMUSICMOV BX,DS:BPCALL SOUNDFADD SI,2ADD BP,2JMP FREQENDMUSIC:RETMU
22、SIC ENDP;SOUNDF PROC NEARPUSH AXPUSH BXPUSH CXPUSH DXPUSH DIMOV AL,0B6HOUT 43H,ALMOV DX,12HMOV AX,348CHDIV DIOUT 42H,ALMOV AL,AHOUT 42H,ALIN AL,61HMOV AH,ALOR AL,3OUT 61H,ALWAIT1:MOV CX,6000CALL WAITFDEC BXJNZ WAIT1MOV AL,AHOUT 61H,ALPOP DIPOP DXPOP CXPOP BXPOP AXRETSOUNDF ENDP;WAITF PROC NEARPUSH AXWAITF1:IN AL,61HAND AL,10HCMP AL,AHJE WAITF1MOV AH,ALLOOP WAITF1POP AXRETWAITF ENDP;CODE ENDSEND MAIN