汇编实验一
1-1. 从3500H内存单元开始建立0~15共16个数据(建立的数据为00H,01H~09H.0AH~0FH)。并运行之,检查记录结果。
DATAS SEGMENT ORG 3500H
MEM1 DB 16 DUP(?);此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV DI,3500H MOV CX,0010H MOV AH,00H SAHF
MOV AL,00H A1:MOV [DI],AL INC DI INC AL
LOOP A1;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS
END START
-U
1732:0000 B8E113 MOV AX,13E1 1732:0003 8ED8 MOV DS,AX 1732:0005 BF0035 MOV DI,3500 1732:0008 B91000 MOV CX,0010 1732:000B B400 MOV AH,00 1732:000D 9E SAHF
1732:000E B000 MOV AL,00 1732:0010 8805 MOV [DI],AL 1732:0012 47 INC DI 1732:0013 FEC0 INC AL 1732:0015 E2F9 LOOP 0010
1732:0017 B44C MOV AH,4C 1732:0019 CD21 INT 21 -G=0000 0017
AX=0010 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=3510
DS=131 ES=13D1 SS=13E1 CS=1732 IP=0017 NV UP EI PL NZ AC PO NC
1732:0017 B44C MOV AH,4C -D 13E1:3500
13E1:3500 00 01 02 03 04 05 06 07-08 09 0A 0B 0C 0D 0E 0F ................ 13E1:3510 B8 E1 13 8E D8 BF 00 35-B9 10 00 B4 00 9E B0 00 .......5........ 13E1:3520 88 05 47 FE C0 E2 F9 B4-4C CD 21 00 00 00 00 00 ..G.....L.!.....
13E1:3530 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:3540 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
1-2. 如果建立的数据为BCD码表示的十进制数据(建立的数据应为00H,01H~09H,10H~15H),应如何修改上述程序. 并运行之,检查记录结果。
DATAS SEGMENT ORG 3500H
MEM1 DB 16 DUP(?);此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV DI,3500H MOV CX,0010H MOV AH,00H SAHF MOV AL,00H A1:ADD AL,00H DAA
MOV [DI],AL INC DI
INC AL
LOOP A1;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS
END START
-U
1732:0000 B8E113 MOV AX,13E1 1732:0003 8ED8 MOV DS,AX 1732:0005 BF0035 MOV DI,3500 1732:0008 B91000 MOV CX,0010 1732:000B B400 MOV AH,00 1732:000D 9E SAHF
1732:000E B000 MOV AL,00 1732:0010 8805 MOV [DI],AL 1732:0012 47 INC DI 1732:0013 FEC0 INC AL 1732:0015 E2F9 LOOP 0010 1732:0017 B44C MOV AH,4C 1732:0019 CD21 INT 21
-G=0000 0017
AX=0010 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=3510
DS=13E1 ES=13D1 SS=13E1 CS=1732 IP=0017 NV UP EI PL NZ AC PO NC
1732:0017 B44C MOV AH,4C -D 13E1:3500
13E1:3500 00 01 02 03 04 05 06 07-08 09 10 11 12 13 14 15 ................ 13E1:3510 B8 E1 13 8E D8 BF 00 35-B9 10 00 B4 00 9E B0 00 .......5........ 13E1:3520 04 00 27 88 05 47 FE C0-E2 F6 B4 4C CD 21 00 00 ..'..G.....L.!.. 13E1:3530 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:3540 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1-3.编程完成1+2+3+4+5+6+7+8+9运算。
DATAS SEGMENT ORG 3500H
MEM1 DB 9 DUP(?)
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV MEM1,01H MOV BL,MEM1 MOV AL,00H MOV CX,9 MOV AH,0 A1:ADD AL,BL ADC AH,0 INC BL LOOP A1
;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS
END START
-U
1732:0000 B8E113 MOV AX,13E1 1732:0003 8ED8 MOV DS,AX
1732:0005 C606003501 MOV BYTE PTR [3500],01 1732:000A 8A1E0035 MOV BL,[3500] 1732:000E B000 MOV AL,00 1732:0010 B90900 MOV CX,0009 1732:0013 B400 MOV AH,00 1732:0015 02C3 ADD AL,BL 1732:0017 80D400 ADC AH,00 1732:001A FEC3 INC BL 1732:001C E2F7 LOOP 0015 1732:001E B44C MOV AH,4C -G=0000 001E
AX=002D BX=000A CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=13E1 ES=13D1 SS=13E1 CS=1732 IP=001E NV UP EI PL NZ NA PE NC
1732:001E B44C MOV AH,4C
1-4.编程完成1+2+3+4+5+6+7+8+~+100运算。
DATAS SEGMENT SUM DW ? DATAS ENDS
STACKS SEGMENT STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV AX,0 MOV BX,1 MOV CX,100 A1:ADD AX,BX INC BX DEC CX JNZ A1
MOV SUM,AX MOV AH,4CH INT 21H CODES ENDS END START 实验结果:
-U
172A:0000 B8D913 MOV AX,13D9 172A:0003 8ED8 MOV DS,AX
172A:0005 C606003501 MOV BYTE PTR [3500],01 172A:000A 8A1E0035 MOV BL,[3500] 172A:000E B000 MOV AL,00 172A:0010 B900 MOV CX,00 172A:0013 B400 MOV AH,00 172A:0015 02C3 ADD AL,BL 172A:0017 80D400 ADC AH,00 172A:001A FEC3 INC BL 172A:001C E2F7 LOOP 0015 172A:001E A30135 MOV [3501],AX -U
172A:0021 B44C MOV AH,4C 172A:0023 CD21 INT 21 -G=0000 0021
AX=13BA BX=0065 CX=0000 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=13D9 ES=13C9 SS=13D9 CS=172A IP=0021 NV UP EI PL NZ NA PE NC 172A:0021 B44C MOV AH,4C -DDS:3500
13D9:3500 01 BA 13 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13D9:3510 B8 D9 13 8E D8 C6 06 00-35 01 8A 1E 00 35 B0 00 ........5....5.. 13D9:3520 B9 00 B4 00 02 C3 80-D4 00 FE C3 E2 F7 A3 01 .d.............. 13D9:3530 35 B4 4C CD 21 00 00 00-00 00 00 00 00 00 00 00 5.L.!...........
1-5.将内存3500H单元开始存放的0~9共10个字节数传递到3600H单元开始的数据区中(同一段内传送)。
DATAS SEGMENT ORG 3500H
MEM1 DB 0,1,2,3,4,5,6,7,8,9 ORG 3600H
MEM2 DB 10 DUP(?);此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV CX,10 LEA SI,MEM1 LEA DI,MEM2 A1: MOV AL,[SI]; MOV [DI], AL DEC CX LOOP A1 MOV AH,4CH INT 21H CODES ENDS
END START
-U
1742:0000 B8E113 MOV AX,13E1 1742:0003 8ED8 MOV DS,AX 1742:0005 B90A00 MOV CX,000A 1742:0008 8D360035 LEA SI,[3500] 1742:000C 8D3E0036 LEA DI,[3600] 1742:0010 8A04 MOV AL,[SI] 1742:0012 8805 MOV [DI],AL 1742:0014 49 DEC CX 1742:0015 E2F9 LOOP 0010 1742:0017 B44C MOV AH,4C 1742:0019 CD21 INT 21
1742:001B 0000 ADD [BX+SI],AL 1742:001D 0000 ADD [BX+SI],AL 1742:001F 0000 ADD [BX+SI],AL
-G=0000 0017
AX=1300 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=3500 DI=3600 DS=13E1 ES=13D1 SS=13E1 CS=1742 IP=0017 NV UP EI PL NZ NA PO NC 1742:0017 B44C MOV AH,4C
-D 13E1:3500
13E1:3500 00 01 02 03 04 05 06 07-08 09 00 00 00 00 00 00 ................ 13E1:3510 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:3520 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:3530 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ -D 13D1:3600
13D1:3600 00 01 02 03 04 05 06 07-08 09 00 00 00 00 00 00 ................ 13D1:3610 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13D1:3620 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13D1:3630 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1-6.在1-5题中,如果采用字数据传送,应该如何修改程序?并运行之,检查记录结果。
DATAS SEGMENT ORG 3500H
MEM1 DB 0,1,2,3,4,5,6,7,8,9 ORG 3600H
MEM2 DB 10 DUP(?);此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV CX,5 LEA SI,MEM1 LEA DI,MEM2 A1: MOV AX,[SI]; MOV [DI],AX INC SI INC SI INC DI INC DI LOOP A1 MOV AH,4CH
INT 21H CODES ENDS
END START
-U
1735:0000 B8D413 MOV AX,13D4 1735:0003 8ED8 MOV DS,AX 1735:0005 B90500 MOV CX,0005 1735:0008 8D360035 LEA SI,[3500] 1735:000C 8D3E0036 LEA DI,[3600] 1735:0010 8B04 MOV AX,[SI] 1735:0012 05 MOV [DI],AX 1735:0014 46 INC SI 1735:0015 46 INC SI 1735:0016 47 INC DI 1735:0017 47 INC DI 1735:0018 E2F6 LOOP 0010 1735:001A B44C MOV AH,4C 1735:001C CD21 INT 21
1735:001E 0000 ADD [BX+SI],AL -G 0000 001C
AX=0000 BX=0000 CX=362E DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=13C4 ES=13C4 SS=13D4 CS=1735 IP=0000 NV UP EI PL NZ NA PO NC
1735:0000 B8D413 MOV AX,13D4
1-7.在1-5题中,如果采用串传送指令(MOVSB,MOVSW指令)如何修改程序?并运行之,检查记录结果。
DATAS SEGMENT ORG 3500H
MEM1 DB 0,1,2,3,4,5,6,7,8,9 ORG 3600H
MEM2 DB 10 DUP(?);此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV CX,5 LEA SI,MEM1
LEA DI,MEM2 A1: MOVSB DEC CX LOOP A1 MOV AH,4CH INT 21H CODES ENDS
END START
-G=0000 0012
AX=13E1 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=350A DI=360A DS=13E1 ES=13D1 SS=13E1 CS=1742 IP=0012 NV UP EI PL NZ NA PO NC 1742:0012 B44C MOV AH,4C -D 13E1:3500
13E1:3500 00 01 02 03 04 05 06 07-08 09 00 00 00 00 00 00 ................ 13E1:3510 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:3520 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:3530 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ -D 13D1:3600
13D1:3600 00 01 02 03 04 05 06 07-08 09 00 00 00 00 00 00 ................ 13D1:3610 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13D1:3620 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13D1:3630 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1.8编制一程序,求出下列公式中的Z值,并存放在RESULT单元中。Z=[(X+Y)*8-X]/2分别放在VARX、VARY单元中。 实验源程序:
TITLE EXAMPLE3-41 DATAS SEGMENT VARX DW 6 VARY DW 7 RESULT DW ? DATAS ENDS
STACKS SEGMENT STACK DW 50 DUP(?) STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
MOV AX,STACKS MOV SS,AX MOV DX,VARX
ADD DX,VARY MOV CL,3 SAL DX,CL SUB DX,VARX SAR DX,1
MOV RESULT,DX MOV AH,4CH INT 21H CODES ENDS END START
实验结果: -U
13C7:0000 B8BF13 MOV AX,13BF 13C7:0003 8ED8 MOV DS,AX 13C7:0005 B8C013 MOV AX,13C0 13C7:0008 8ED0 MOV SS,AX
13C7:000A 8B160000 MOV DX,[0000] 13C7:000E 03160200 ADD DX,[0002] 13C7:0012 B103 MOV CL,03 13C7:0014 D3E2 SHL DX,CL 13C7:0016 2B160000 SUB DX,[0000] 13C7:001A D1FA SAR DX,1
13C7:001C 160400 MOV [0004],DX 13C7:0020 B44C MOV AH,4C -G=0000 0020
AX=13C0 BX=0000 CX=0003 DX=0031 SP=00 BP=0000 SI=0000 DI=0000 DS=13BF ES=13AF SS=13C0 CS=13C7 IP=0020 NV UP EI PL NZ NA PO NC 13C7:0020 B44C MOV AH,4C
-D 13BF:0000
13BF:0000 06 00 07 00 31 00 00 00-00 00 00 00 00 00 00 00 ....1........... 13BF:0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13BF:0020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13BF:0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
汇编实验二
2-1 教材161页 例题3.39自内存TABLE开始连续16个单元内存放着0~15的平方值(即平方表),查表求任意数的平方值并将结果存入RESULT单元中。
DATAS SEGMENT
TABLE DB 0,1,4,9,16,25,36,49,,81 DB 100,121,144,169,196,225 DATA DB 4
RESULT DB ? DATAS ENDS
STACKS SEGMENT
DW 50 DUP(0);此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
MOV AX,STACKS MOV SS,AX
MOV BX,OFFSET TABLE MOV AH,0 MOV AL,DATA ADD BX,AX MOV AL,[BX]
MOV RESULT,AL;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS END START
-U
13ED:0000 B8E413 MOV AX,13E4 13ED:0003 8ED8 MOV DS,AX 13ED:0005 B8E613 MOV AX,13E6 13ED:0008 8ED0 MOV SS,AX 13ED:000A BB0000 MOV BX,0000 13ED:000D B400 MOV AH,00 13ED:000F A01000 MOV AL,[0010] 13ED:0012 03D8 ADD BX,AX 13ED:0014 8A07 MOV AL,[BX] 13ED:0016 A21100 MOV [0011],AL 13ED:0019 B44C MOV AH,4C 13ED:001B CD21 INT 21 -G=0000 0019
AX=0010 BX=0004 CX=00AD DX=0000 SP=00 BP=0000 SI=0000 DI=0000 DS=13E4 ES=13D4 SS=13E6 CS=13ED IP=0019 NV UP EI PL NZ NA PO NC 13ED:0019 B44C MOV AH,4C
-D 13E4:0000
13E4:0000 00 01 04 09 10 19 24 31-40 51 79 90 A9 C4 E1 ......$1@Qdy.... 13E4:0010 04 10 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E4:0020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E4:0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E4:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E4:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
2.2编程完成 Z=3x+4y-4,其中x、y为字节单元,z为字单元。如果x、y为字单元,z为双字单元,,如何修改程序,并运行,给出结果
DATAS SEGMENT X DB 4 Y DB 5 Z DW ? DATAS ENDS
STACKS SEGMENT STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX LEA DI,Z MOV AL,X MOV BL,3 MUL BL MOV BL,Y MOV CL,2 SAL BL,CL MOV BH,0 ADD AX,BX SUB AX,4 MOV [DI],AX MOV AH,4CH INT 21H CODES ENDS END START
-U
13E5:0000 B8E413 MOV AX,13E4 13E5:0003 8ED8 MOV DS,AX
13E5:0005 8D3E0200 LEA DI,[0002] 13E5:0009 A00000 MOV AL,[0000] 13E5:000C B303 MOV BL,03 13E5:000E F6E3 MUL BL 13E5:0010 8A1E0100 MOV BL,[0001] 13E5:0014 B102 MOV CL,02 13E5:0016 D2E3 SHL BL,CL 13E5:0018 B700 MOV BH,00 13E5:001A 03C3 ADD AX,BX 13E5:001C 83E804 SUB AX,+04 13E5:001F 05 MOV [DI],AX
-G=0000 0021
AX=001C BX=0014 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0002 DS=13E4 ES=13D4 SS=13E4 CS=13E5 IP=0021 NV UP EI PL NZ AC PO NC 13E5:0021 B44C MOV AH,4C
-D13E4:0002
13E4:0000 1C 00 00 00 00 00-00 00 00 00 00 00 00 00 .............. 13E4:0010 B8 E4 13 8E D8 8D 3E 02-00 A0 00 00 B3 03 F6 E3 ......>......... 13E4:0020 8A 1E 01 00 B1 02 D2 E3-B7 00 03 C3 83 E8 04 ................ 13E4:0030 05 B4 4C CD 21 00 00 00-00 00 00 00 00 00 00 00 ..L.!........... 13E4:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 2.2修改
DATAS SEGMENT X DW 4 Y DW 5
Z DW ?,? DATAS ENDS
STACKS SEGMENT STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX XOR AX,AX XOR DX,DX LEA DI,Z MOV AX,X MOV BX,3 MUL BX MOV BX,Y MOV CL,2 SAL BX,CL ADD AX,BX ADC DX,00H SUB AX,4 SBB DX,00H MOV [DI],AX
MOV [DI+2],DX MOV AH,4CH INT 21H CODES ENDS END START
-U
13C7:0000 B8C613 MOV AX,13C6 13C7:0003 8ED8 MOV DS,AX 13C7:0005 33C0 XOR AX,AX 13C7:0007 33D2 XOR DX,DX 13C7:0009 8D3E0400 LEA DI,[0004] 13C7:000D A10000 MOV AX,[0000] 13C7:0010 BB0300 MOV BX,0003 13C7:0013 F7E3 MUL BX 13C7:0015 8B1E0200 MOV BX,[0002] 13C7:0019 B102 MOV CL,02 13C7:001B D3E3 SHL BX,CL 13C7:001D 03C3 ADD AX,BX 13C7:001F 83D200 ADC DX,+00 13C7:0022 83E804 SUB AX,+04 13C7:0025 05 MOV [DI],AX 13C7:0027 5502 MOV [DI+02],DX 13C7:002A B44C MOV AH,4C 13C7:002C CD21 INT 21 -G=0000 002A
AX=001C BX=0014 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0004 DS=13C6 ES=13B6 SS=13C6 CS=13C7 IP=002A NV UP EI PL NZ AC PO NC 13C7:002A B44C MOV AH,4C -DDS:0004
13C6:0000 1C 00 00 00-00 00 00 00 00 00 00 00 ............ 13C6:0010 B8 C6 13 8E D8 33 C0 33-D2 8D 3E 04 00 A1 00 00 .....3.3..>..... 13C6:0020 BB 03 00 F7 E3 8B 1E 02-00 B1 02 D3 E3 03 C3 83 ................ 13C6:0030 D2 00 83 E8 04 05 -55 02 B4 4C CD 21 00 00 ........U..L.!.. 13C6:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13C6:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 2-3、编程求若干字节数的累加和,和的结果小于32767(即累加和不超过16位二进制数。
DATAS SEGMENT
TABLE DW 10,12,22,55,67,23 SUM DB ? DATAS ENDS STACKS SEGMENT STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX LEA SI,TABLE
MOV CX,6 XOR AX,AX NEXT:ADD AL,[SI] ADC AH,0 INC SI LOOP NEXT
NEXT1:MOV [SI],AX MOV AH,4CH INT 21H CODES ENDS END START
-U
13E5:0000 B8E413 MOV AX,13E4 13E5:0003 8ED8 MOV DS,AX
13E5:0005 8D360000 LEA SI,[0000] 13E5:0009 B90600 MOV CX,0006 13E5:000C 33C0 XOR AX,AX 13E5:000E 0204 ADD AL,[SI] 13E5:0010 80D400 ADC AH,00 13E5:0013 46 INC SI 13E5:0014 E2F8 LOOP 000E 13E5:0016 04 MOV [SI],AX 13E5:0018 B44C MOV AH,4C 13E5:001A CD21 INT 21
13E5:001C 0000 ADD [BX+SI],AL 13E5:001E 0000 ADD [BX+SI],AL
-D13E4:0000
13E4:0000 0A 0C 16 37 43 17 BD 00-00 00 00 00 00 00 00 00 ...7C........... 13E4:0010 B8 E4 13 8E D8 8D 36 00-00 B9 06 00 33 C0 02 04 ......6.....3... 13E4:0020 80 D4 00 46 E2 F8 A2 06-00 B4 4C CD 21 00 00 00 ...F......L.!... 13E4:0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E4:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 2-4、从BUFFER单元开始存放若干数据,求其中负数的个数存入MDAT字节单元中。
DATAS SEGMENT
BUFFER DB 22,-16,26,-17,,21 MDAT DB ? DATAS ENDS STACKS SEGMENT STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX XOR DX,DX
LEA SI,BUFFER MOV CX,6
NEXT:MOV AL,[SI] CMP AL,0 JGE NEXT1 INC DX NEXT1:INC SI LOOP NEXT MOV MDAT,AX MOV AH,4CH INT 21H CODES ENDS END START
-U
13E5:0000 B8E413 MOV AX,13E4 13E5:0003 8ED8 MOV DS,AX 13E5:0005 32D2 XOR DL,DL
13E5:0007 8D360000 LEA SI,[0000] 13E5:000B B90600 MOV CX,0006 13E5:000E 8A04 MOV AL,[SI] 13E5:0010 3C00 CMP AL,00 13E5:0012 7D01 JGE 0015 13E5:0014 42 INC DX 13E5:0015 46 INC SI 13E5:0016 E2F6 LOOP 000E 13E5:0018 88160600 MOV [0006],DL 13E5:001C B44C MOV AH,4C 13E5:001E CD21 INT 21 -G=0000 001C
AX=1315 BX=0000 CX=0000 DX=0002 SP=0000 BP=0000 SI=0006 DI=0000 DS=13E4 ES=13D4 SS=13E4 CS=13E5 IP=001C NV UP EI PL NZ NA PE NC 13E5:001C B44C MOV AH,4C -D13E4:0000
13E4:0000 16 F0 1A EF 40 15 02 00-00 00 00 00 00 00 00 00 ....@........... 13E4:0010 B8 E4 13 8E D8 32 D2 8D-36 00 00 B9 06 00 8A 04 .....2..6....... 13E4:0020 3C 00 7D 01 42 46 E2 F6-88 16 06 00 B4 4C CD 21 <.}.BF.......L.! 13E4:0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E4:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 2-5.修改程序2-3,使其能求出数据区中正数的个数,存入PDAT单元中。
DATAS SEGMENT
BUFFER DB 22,-16,26,-17,,21 PDAT DB ? DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX XOR DL,DL
LEA SI,BUFFER MOV CX,6
NEXT:MOV AL,[SI] CMP AL,0 JLE NEXT1 INC DX NEXT1:INC SI LOOP NEXT MOV PDAT,DL MOV AH,4CH INT 21H CODES ENDS END START
-U
13E5:0000 B8E413 MOV AX,13E4 13E5:0003 8ED8 MOV DS,AX 13E5:0005 32D2 XOR DL,DL
13E5:0007 8D360000 LEA SI,[0000] 13E5:000B B90600 MOV CX,0006 13E5:000E 8A04 MOV AL,[SI] 13E5:0010 3C00 CMP AL,00 13E5:0012 7E01 JLE 0015 13E5:0014 42 INC DX 13E5:0015 46 INC SI 13E5:0016 E2F6 LOOP 000E 13E5:0018 88160600 MOV [0006],DL 13E5:001C B44C MOV AH,4C 13E5:001E CD21 INT 21
-G=0000 001C
AX=1315 BX=0000 CX=0000 DX=0004 SP=0000 BP=0000 SI=0006 DI=0000 DS=13E4 ES=13D4 SS=13E4 CS=13E5 IP=001C NV UP EI PL NZ NA PE NC
13E5:001C B44C MOV AH,4C -D13E4:0000
13E4:0000 16 F0 1A EF 40 15 04 00-00 00 00 00 00 00 00 00 ....@........... 13E4:0010 B8 E4 13 8E D8 32 D2 8D-36 00 00 B9 06 00 8A 04 .....2..6....... 13E4:0020 3C 00 7E 01 42 46 E2 F6-88 16 06 00 B4 4C CD 21 <.~.BF.......L.! 13E4:0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E4:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 2-6. 将某数据区内正数、负数和零分别放在PDAT,MDAT,ZDAT开始的单元中。
DATAS SEGMENT
BUFFER DB 22,-16,26,-17,,0 PDAT DB 6 DUP (?) MDAT DB 6 DUP (?) DATAS ENDS
STACKS SEGMENT
ZDAT DB 6 DUP (?) STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
MOV AX,STACKS MOV SS,AX LEA DI,PDAT LEA BX,MDAT LEA BP,ZDAT MOV CX,6 CLD
CHECK: LODSB OR AL,AL JS NEXT1 JZ NEXT2 MOV [DI],AL INC DI JMP NEXT
NEXT1:MOV [BX],AL INC BX JMP NEXT
NEXT2:MOV [BP],AL INC BP JMP NEXT NEXT:DEC CX JNZ CHECK
MOV AH,4CH INT 21H CODES ENDS END START
-U
13F4:0000 B8F113 MOV AX,13F1 13F4:0003 8ED8 MOV DS,AX 13F4:0005 B8F313 MOV AX,13F3 13F4:0008 8ED0 MOV SS,AX
13F4:000A 8D3E0600 LEA DI,[0006] 13F4:000E 8D1E0C00 LEA BX,[000C] 13F4:0012 8D2E0000 LEA BP,[0000] 13F4:0016 B90600 MOV CX,0006 13F4:0019 FC CLD 13F4:001A AC LODSB
13F4:001B 0AC0 OR AL,AL 13F4:001D 7807 JS 0026 13F4:001F 740A JZ 002B -U
13F4:0021 8805 MOV [DI],AL 13F4:0023 47 INC DI 13F4:0024 EB0B JMP 0031 13F4:0026 8807 MOV [BX],AL 13F4:0028 43 INC BX 13F4:0029 EB06 JMP 0031 13F4:002B 884600 MOV [BP+00],AL 13F4:002E 45 INC BP 13F4:002F EB00 JMP 0031 13F4:0031 49 DEC CX 13F4:0032 75E6 JNZ 001A 13F4:0034 B44C MOV AH,4C 13F4:0036 CD21 INT 21
-G=0000 0034
AX=1300 BX=000E CX=0000 DX=0000 SP=0000 BP=0001 SI=0006 DI=0009 DS=13F1 ES=13E1 SS=13F3 CS=13F4 IP=0034 NV UP EI PL ZR NA PE NC 13F4:0034 B44C MOV AH,4C -D13F1:0000
13F1:0000 16 F0 1A EF 40 00 16 1A-40 00 00 00 F0 EF 00 00 ....@...@....... 13F1:0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13F1:0020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13F1:0030 B8 F1 13 8E D8 B8 F3 13-8E D0 8D 3E 06 00 8D 1E ...........>....
13F1:0040 0C 00 8D 2E 00 00 B9 06-00 FC AC 0A C0 78 07 74 .............x.t 13F1:0050 0A 88 05 47 EB 0B 88 07-43 EB 06 88 46 00 45 EB ...G....C...F.E. 13F1:0060 00 49 75 E6 B4 4C CD 21-00 00 00 00 00 00 00 00 .Iu..L.!........ 13F1:0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ -D13F3:0000
13F3:0000 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13F3:0010 B8 F1 13 8E D8 B8 F3 13-8E D0 8D 3E 06 00 8D 1E ...........>.... 13F3:0020 0C 00 8D 2E 00 00 B9 06-00 FC AC 0A C0 78 07 74 .............x.t 13F3:0030 0A 88 05 47 EB 0B 88 07-43 EB 06 88 46 00 45 EB ...G....C...F.E. 13F3:0040 00 49 75 E6 B4 4C CD 21-00 00 00 00 00 00 00 00 .Iu..L.!........ 13F3:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 2-7、求无符号字节序列中的最小值,放入MDATA单元
DATAS SEGMENT
BUFFER DB 10,12,22,55,67,23
MDAT DB ?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
LEA SI,BUFFER MOV AL,[SI] NEXT:INC SI
CMP AL,[SI] JNC DONE MOV AL,[SI] LOOP NEXT DONE:MOV MDAT,AL MOV AH,4CH INT 21H CODES ENDS END START
-U
13E5:0000 B8E413 MOV AX,13E4 13E5:0003 8ED8 MOV DS,AX 13E5:0005 8D360000 LEA SI,[0000]
13E5:0009 8A04 MOV AL,[SI] 13E5:000B 46 INC SI 13E5:000C 3A04 CMP AL,[SI] 13E5:000E 7304 JNB 0014 13E5:0010 8A04 MOV AL,[SI] 13E5:0012 E2F7 LOOP 000B
13E5:0014 A20600 MOV [0006],AL 13E5:0017 B44C MOV AH,4C 13E5:0019 CD21 INT 21
13E5:001B 0000 ADD [BX+SI],AL 13E5:001D 0000 ADD [BX+SI],AL 13E5:001F 0000 ADD [BX+SI],AL -G0000 0017
AX=0000 BX=0000 CX=002B DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=13D4 ES=13D4 SS=13E4 CS=13E5 IP=0000 NV UP EI PL NZ NA PO NC 13E5:0000 B8E413 MOV AX,13E4 -D13D4:0000
13D4:0000 CD 20 FF 9F 00 9A F0 FE-1D F0 4F 03 E3 0D 8A 03 . ........O..... 13D4:0010 E3 0D 17 03 E3 0D D2 0D-01 01 01 00 02 FF FF FF ................ 13D4:0020 FF FF FF FF FF FF FF FF-FF FF FF FF 90 13 F1 49 ...............I 13D4:0030 E3 0D 14 00 18 00 D4 13-FF FF FF FF 00 00 00 00 ................ 13D4:0040 05 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13D4:0050 CD 21 CB 00 00 00 00 00-00 00 00 00 00 20 20 20 .!........... 13D4:0060 20 20 20 20 20 20 20 20-00 00 00 00 00 20 20 20 ..... 13D4:0070 20 20 20 20 20 20 20 20-00 00 00 00 00 00 00 00 ........ 2-8.若求有符号字型序列中的最大值和最小值,放入MDATA单元和NDATA单元
DATAS SEGMENT
BUFFER DB -3,6,9,15,-6 MDATA DB ? NDATA DB ? DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX LODSB BUFFER
MOV CX,5 CLD
MOV MDATA,AL MOV NDATA,AL DEC CX NEXT:LODSB
CMP AL ,MDATA JG NEXT1
CMP AL,NDATA JL NEXT2
NEXT1:MOV MDATA,AL JMP DONE
NEXT2:MOV NDATA,AL DONE: LOOP NEXT MOV AH,4CH
INT 21H
CODES ENDS END START
-u
13DD:0000 B8DC13 MOV AX,13DC 13DD:0003 8ED8 MOV DS,AX 13DD:0005 AC LODSB
13DD:0006 B90500 MOV CX,0005 13DD:0009 FC CLD
13DD:000A A20500 MOV [0005],AL 13DD:000D A20600 MOV [0006],AL 13DD:0010 49 DEC CX 13DD:0011 AC LODSB
13DD:0012 3A060500 CMP AL,[0005] 13DD:0016 7F06 JG 001E 13DD:0018 3A060600 CMP AL,[0006] 13DD:001C 7C05 JL 0023 13DD:001E A20500 MOV [0005],AL -u
13DD:0021 EB03 JMP 0026
13DD:0023 A20600 MOV [0006],AL 13DD:0026 E2E9 LOOP 0011 13DD:0028 B44C MOV AH,4C 13DD:002A CD21 INT 21 -G=0000 0028
AX=13FA BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0005 DI=0000 DS=13F1 ES=13E1 SS=13F1 CS=13F2 IP=0028 NV UP EI NG NZ AC PO CY 13F2:0028 B44C MOV AH,4C
-DDS:0000
13F1:0000 FD 06 09 0F FA 0F FA 00-00 00 00 00 00 00 00 00 ................ 13F1:0010 B8 F1 13 8E D8 AC B9 05-00 FC A2 05 00 A2 06 00 ................ 13F1:0020 49 AC 3A 06 05 00 7F 06-3A 06 06 00 7C 05 A2 05 I.:.....:...|... 13F1:0030 00 EB 03 A2 06 00 E2 E9-B4 4C CD 21 00 00 00 00 .........L.!.... 13F1:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13F1:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 2-9,.调用DOS功能,在屏幕上显示 0~9.
DATAS SEGMENT
BUFFER DB '01234567' DATAS ENDS
STACKS SEGMENT STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
LEA SI,BUFFER MOV CX,10 NEXT:MOV AH,2 MOV DL,[SI] INC SI INT 21H LOOP NEXT MOV AH,4CH INT 21H CODES ENDS END START
2-10、调用DOS功能,在屏幕上显示 0+1+2+3的结果。
DATAS SEGMENT
BUFFER DB 1,2,3 MDATA DB ? DATAS ENDS
STACKS SEGMENT STACKS ENDS CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
LEA SI,BUFFER MOV CX,3
MOV AL,0
NEXT:MOV BL,[SI] ADD AL,BL INC SI LOOP NEXT ADD AL,30H MOV DL,AL MOV AH,2 INT 21H
MOV MDATA,AL MOV AH,4CH INT 21H CODES ENDS END START
-U
13E2:0000 B8E113 MOV AX,13E1 13E2:0003 8ED8 MOV DS,AX 13E2:0005 8D360000 LEA SI,[0000] 13E2:0009 B90300 MOV CX,0003 13E2:000C B000 MOV AL,00 13E2:000E 8A1C MOV BL,[SI] 13E2:0010 02C3 ADD AL,BL 13E2:0012 46 INC SI 13E2:0013 E2F9 LOOP 000E 13E2:0015 0430 ADD AL,30 13E2:0017 8AD0 MOV DL,AL 13E2:0019 B402 MOV AH,02 13E2:001B CD21 INT 21
13E2:001D A20300 MOV [0003],AL 13E2:0020 B44C MOV AH,4C -G=0000 0020
6
AX=0236 BX=0003 CX=0000 DX=0036 SP=0000 BP=0000 SI=0003 DI=0000 DS=13E1 ES=13D1 SS=13E1 CS=13E2 IP=0020 NV UP EI PL NZ NA PE NC 13E2:0020 B44C MOV AH,4C -D 13E1:0000
13E1:0000 01 02 03 36 00 00 00 00-00 00 00 00 00 00 00 00 ...6............ 13E1:0010 B8 E1 13 8E D8 8D 36 00-00 B9 03 00 B0 00 8A 1C ......6......... 13E1:0020 02 C3 46 E2 F9 04 30 8A-D0 B4 02 CD 21 A2 03 00 ..F...0.....!... 13E1:0030 B4 4C CD 21 00 00 00 00-00 00 00 00 00 00 00 00 .L.!............ 13E1:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
汇编实验三
3.1已知从DS:2200H,ES:3200H单元起分别存放20个ASCII的字符。找出这两个字符串中第一个不同字符的位置(段内偏地址),并放入DS:22A0H开始的连续两个字单元中。请设计完成此任务的程序段。
(1)使用通常用的比较指令(CMP)实现;
DATAS SEGMENT ORG 2200H
A1 DB '1234567ABCDEFGHIJK' ORG 3200H
A2 DB '1234567OPQRSTUVWXY' ORG 22A0H
RESULT DW ?,?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
MOV ES,AX LEA SI,A1 LEA DI,A2 MOV CX,20
NEXT1:MOV BL,[SI] CMP BL,[DI] JZ NEXT2 MOV BX,SI
MOV RESULT,BX MOV BX,DI
MOV RESULT+2,BX JMP DONE NEXT2:INC SI INC DI
LOOP NEXT1;此处输入代码段代码 DONE: MOV AH,4CH INT 21H CODES ENDS END START
-U
1703:0000 B8E113 MOV AX,13E1 1703:0003 8ED8 MOV DS,AX 1703:0005 8EC0 MOV ES,AX
1703:0007 8D360022 LEA SI,[2200] 1703:000B 8D3E0032 LEA DI,[3200] 1703:000F B91400 MOV CX,0014 1703:0012 8A1C MOV BL,[SI] 1703:0014 3A1D CMP BL,[DI] 1703:0016 740E JZ 0026 1703:0018 8BDE MOV BX,SI 1703:001A 1EA022 MOV [22A0],BX 1703:001E 8BDF MOV BX,DI -U
1703:0020 1EA222 MOV [22A2],BX 1703:0024 EB04 JMP 002A 1703:0026 46 INC SI 1703:0027 47 INC DI 1703:0028 E2E8 LOOP 0012 1703:002A B44C MOV AH,4C 1703:002C CD21 INT 21
1703:002E 0000 ADD [BX+SI],AL 1703:0030 0000 ADD [BX+SI],AL 1703:0032 0000 ADD [BX+SI],AL -G=0000 002A
AX=13E1 BX=3209 CX=000B DX=0000 SP=0000 BP=0000 SI=2209 DI=3209 DS=13E1 ES=13E1 SS=13E1 CS=1703 IP=002A NV UP EI NG NZ AC PO CY 1703:002A B44C MOV AH,4C -D13E1:22A0
13E1:22A0 09 22 09 32 00 00 00 00-00 00 00 00 00 00 00 00 .\".2............ 13E1:22B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:22C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ (2)使用数据串比较指令(CMPSB)实现。
DATAS SEGMENT ORG 2200H
A1 DB '1234567ABCDEFGHIJK' ORG 3200H
A2 DB '1234567OPQRSTUVWXY' ORG 22A0H
RESULT DW ?,?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX
MOV ES,AX LEA SI,A1 LEA DI,A2 MOV CX,20 NEXT1:CMPSB JZ NEXT2 DEC DI
DEC SI MOV BX,SI
MOV RESULT,BX MOV BX,DI
MOV RESULT+2,BX JMP DONE
NEXT2:LOOP NEXT1 ;此处输入代码段代码 DONE: MOV AH,4CH INT 21H CODES ENDS END START
-U
1703:0000 B8E113 MOV AX,13E1 1703:0003 8ED8 MOV DS,AX 1703:0005 8EC0 MOV ES,AX
1703:0007 8D360022 LEA SI,[2200] 1703:000B 8D3E0032 LEA DI,[3200] 1703:000F B91400 MOV CX,0014 1703:0012 A6 CMPSB
1703:0013 7410 JZ 0025 1703:0015 4F DEC DI 1703:0016 4E DEC SI 1703:0017 8BDE MOV BX,SI 1703:0019 1EA022 MOV [22A0],BX 1703:001D 8BDF MOV BX,DI 1703:001F 1EA222 MOV [22A2],BX -U
1703:0023 EB02 JMP 0027
1703:0025 E2EB LOOP 0012 1703:0027 B44C MOV AH,4C 1703:0029 CD21 INT 21
1703:002B 0000 ADD [BX+SI],AL 1703:002D 0000 ADD [BX+SI],AL 1703:002F 0000 ADD [BX+SI],AL 1703:0031 0000 ADD [BX+SI],AL 1703:0033 0000 ADD [BX+SI],AL 1703:0035 0000 ADD [BX+SI],AL 1703:0037 0000 ADD [BX+SI],AL 1703:0039 0000 ADD [BX+SI],AL 1703:003B 0000 ADD [BX+SI],AL -G=0000 0027
AX=13E1 BX=3209 CX=000B DX=0000 SP=0000 BP=0000 SI=2209 DI=3209 DS=13E1 ES=13E1 SS=13E1 CS=1703 IP=0027 NV UP EI PL NZ NA PE CY
1703:0027 B44C MOV AH,4C -D13E1:22A0
13E1:22A0 09 22 09 32 00 00 00 00-00 00 00 00 00 00 00 00 .\".2............ 13E1:22B0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:22C0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 3-2、教材 习题 3.21
编写程序段,在数据区0000H:2000H开始100字节范围内,查找字符'A',若找到,则将偏移地址送入DX,没有找到,则结束。
DATAS SEGMENT ORG 2000H
DATA1 DB'235DB7JKIRAJKII00FKIEMCKD' CNT EQU $-DATA1 ORG 3500H
RESULT DW ?
DATAS ENDS;此处输入数据段代码
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS START:
MOV AX,DATAS MOV DS,AX MOV ES,AX LEA SI,DATA1 MOV CX,CNT
MOV AL,'A' NEXT: SCASB JZ NEXT1 DEC CX JNZ NEXT JMP DONE NEXT1: DEC SI
MOV RESULT,SI;此处输入代码段代码 DONE:MOV AH,4CH INT 21H CODES ENDS END START
-U
1725:0000 B8D413 MOV AX,13D4 1725:0003 8ED8 MOV DS,AX 1725:0005 8EC0 MOV ES,AX
1725:0007 8D360020 LEA SI,[2000] 1725:000B B91900 MOV CX,0019 1725:000E B041 MOV AL,41 1725:0010 AE SCASB 1725:0011 7405 JZ 0018 1725:0013 49 DEC CX 1725:0014 75FA JNZ 0010 1725:0016 EB05 JMP 001D 1725:0018 4E DEC SI
1725:0019 360035 MOV [3500],SI 1725:001D B44C MOV AH,4C 1725:001F CD21 INT 21 -G 0000 001F
AX=0000 BX=0000 CX=3531 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=13C4 ES=13C4 SS=13D4 CS=1725 IP=0000 NV UP EI PL NZ NA PO NC 1725:0000 B8D413 MOV AX,13D4-D13E1:3500 3-3、教材 习题 3.33
编程实现求S=(X2+Y2 )/Z的值,并将结果放入RESULT单元。
DATAS SEGMENT X DB 3 Y DB 4 Z DB 5
RESULT DB ?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV AL,X MOV CL,2 MUL AL MOV BX,AX MOV AL,Y MUL AL ADD AX,BX MOV BL,Z DIV BL
MOV RESULT,AL;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS END START
-U
13E2:0000 B8E113 MOV AX,13E1 13E2:0003 8ED8 MOV DS,AX
13E2:0005 A00000 MOV AL,[0000] 13E2:0008 B102 MOV CL,02 13E2:000A F6E0 MUL AL 13E2:000C 8BD8 MOV BX,AX 13E2:000E A00100 MOV AL,[0001] 13E2:0011 F6E0 MUL AL 13E2:0013 03C3 ADD AX,BX
13E2:0015 8A1E0200 MOV BL,[0002] 13E2:0019 F6F3 DIV BL
13E2:001B A20300 MOV [0003],AL 13E2:001E B44C MOV AH,4C -G=0000 001E
AX=0005 BX=0005 CX=0002 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=13E1 ES=13D1 SS=13E1 CS=13E2 IP=001E NV UP EI PL NZ NA PO NC
13E2:001E B44C MOV AH,4C -DDS:0000
13E1:0000 03 04 05 05 00 00 00 00-00 00 00 00 00 00 00 00 ................
13E1:0010 B8 E1 13 8E D8 A0 00 00-B1 02 F6 E0 8B D8 A0 01 ................ 13E1:0020 00 F6 E0 03 C3 8A 1E 02-00 F6 F3 A2 03 00 B4 4C ...............L 13E1:0030 CD 21 00 00 00 00 00 00-00 00 00 00 00 00 00 00 .!.............. 13E1:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 3-4、教材 习题 3.34
在数据区中,以TABLE开始连续存放0~6的立方值(称为立方表),设任给一数x(0≤x≤6),x在TAB1单元,查表求x的立方值,并把结果存入TAB2单元。
DATAS SEGMENT
TABLE DB 0,1,8,27,,125,216 TAB1 DB 4
TAB2 DB ?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX LEA SI,TABLE MOV AL,TAB1 XOR AH,AH ADD SI,AX MOV BL,[SI]
MOV TAB2,BL;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS END START
-U
13E2:0000 B8E113 MOV AX,13E1 13E2:0003 8ED8 MOV DS,AX 13E2:0005 8D360000 LEA SI,[0000] 13E2:0009 A00700 MOV AL,[0007] 13E2:000C 32E4 XOR AH,AH 13E2:000E 03F0 ADD SI,AX 13E2:0010 8A1C MOV BL,[SI] 13E2:0012 881E0800 MOV [0008],BL 13E2:0016 B44C MOV AH,4C 13E2:0018 CD21 INT 21
13E2:001A 0000 ADD [BX+SI],AL 13E2:001C 0000 ADD [BX+SI],AL
13E2:001E 0000 ADD [BX+SI],AL
-G=0000 0016
AX=0004 BX=0040 CX=002A DX=0000 SP=0000 BP=0000 SI=0004 DI=0000 DS=13E1 ES=13D1 SS=13E1 CS=13E2 IP=0016 NV UP EI PL NZ NA PO NC 13E2:0016 B44C MOV AH,4C -DDS:0000
13E1:0000 00 01 08 1B 40 7D D8 04-40 00 00 00 00 00 00 00 ....@}..@....... 13E1:0010 B8 E1 13 8E D8 8D 36 00-00 A0 07 00 32 E4 03 F0 ......6.....2... 13E1:0020 8A 1C 88 1E 08 00 B4 4C-CD 21 00 00 00 00 00 00 .......L.!...... 13E1:0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 3-5、教材 习题 3.35
以BUF为首址的存储区,存放有若干个有符号字数据,试编写一程序求出其中负数的平均值(负数之和>-32768),并存放在MEA2单元中
DATAS SEGMENT
BUF DW -5,3,4,-5,8,-5,99
MEA2 DB ?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX LEA SI,BUF XOR CH,CH MOV CL,7 XOR AX,AX
A1:MOV BX,[SI] TEST BX,8000H JZ A2 INC CH ADD AX,BX A2:INC SI INC SI DEC CL JNZ A1 IDIV CH
MOV MEA2,AL;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS END START
-u
13D5:0000 B8D413 MOV AX,13D4 13D5:0003 8ED8 MOV DS,AX 13D5:0005 8D360000 LEA SI,[0000 13D5:0009 32ED XOR CH,CH 13D5:000B B107 MOV CL,07 13D5:000D 33C0 XOR AX,AX 13D5:000F 8B1C MOV BX,[SI] 13D5:0011 F7C30080 TEST BX,8000 13D5:0015 7404 JZ 001B 13D5:0017 FEC5 INC CH 13D5:0019 03C3 ADD AX,BX 13D5:001B 46 INC SI 13D5:001C 46 INC SI 13D5:001D FEC9 DEC CL 13D5:001F 75EE JNZ 000F -u
13D5:0021 F6FD IDIV CH
13D5:0023 A20E00 MOV [000E],AL 13D5:0026 B44C MOV AH,4C 13D5:0028 CD21 INT 21
13D5:002A 0000 ADD [BX+SI],AL 13D5:002C 0000 ADD [BX+SI],AL 13D5:002E 0000 ADD [BX+SI],AL 13D5:0030 0000 ADD [BX+SI],AL
13D5:0032 0000 ADD [BX+SI],AL-G=0000 0026
AX=00FA BX=0059 CX=0300 DX=0000 SP=0000 BP=0000 SI=000E DI=0000 DS=13E1 ES=13D1 SS=13E1 CS=13E2 IP=0026 NV UP EI PL ZR NA PE NC 13E2:0026 B44C MOV AH,4C -D13E1:0000
13E1:0000 16 00 03 00 04 00 FD FF-FA FF F7 FF 59 00 FA 00 ............Y... 13E1:0010 B8 E1 13 8E D8 8D 36 00-00 32 ED B1 07 33 C0 8B ......6..2...3.. 13E1:0020 1C F7 C3 00 80 74 04 FE-C5 03 C3 46 46 FE C9 75 .....t.....FF..u 13E1:0030 EE F6 FD A2 0E 00 B4 4C-CD 21 00 00 00 00 00 00 .......L.!...... 13E1:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 3-6、教材 习题 3.36
编写程序,计算下面函数的值。
2xs3x4x(x0)(0x10) x10
DATAS SEGMENT X DB 20
S DW ?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX MOV AL,X CMP X,10 JLE A1 MOV BL,4 MUL BL MOV S,AX JMP DONE A1: CMP X,0 JL A2 MOV BL,3 MUL BL MOV S,AX JMP DONE A2: MOV BL,2 MUL BL
MOV S,AX;此处输入代码段代码 DONE:MOV AH,4CH INT 21H CODES ENDS
END START
-U
13E2:0000 B8E113 MOV AX,13E1 13E2:0003 8ED8 MOV DS,AX
13E2:0005 A00000 MOV AL,[0000]
13E2:0008 803E00000A CMP BYTE PTR [0000],0A 13E2:000D 7E09 JLE 0018
13E2:000F B304 MOV BL,04
13E2:0011 F6E3 MUL BL
13E2:0013 A30100 MOV [0001],AX 13E2:0016 EB17 JMP 002F
13E2:0018 803E000000 CMP BYTE PTR [0000],00 13E2:001D 7C09 JL 0028 13E2:001F B303 MOV BL,03 -U
13E2:0021 F6E3 MUL BL 13E2:0023 A30100 MOV [0001],AX 13E2:0026 EB07 JMP 002F 13E2:0028 B302 MOV BL,02 13E2:002A F6E3 MUL BL
13E2:002C A30100 MOV [0001],AX 13E2:002F B44C MOV AH,4C 13E2:0031 CD21 INT 21
13E2:0033 0000 ADD [BX+SI],AL 13E2:0035 0000 ADD [BX+SI],AL 13E2:0037 0000 ADD [BX+SI],AL 13E2:0039 0000 ADD [BX+SI],AL 13E2:003B 0000 ADD [BX+SI],AL 13E2:003D 0000 ADD [BX+SI],AL 13E2:003F 0000 ADD [BX+SI],AL -g 0000 0028
AX=0000 BX=0000 CX=003A DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=13C4 ES=13C4 SS=13D4 CS=13D5 IP=0000 NV UP EI PL NZ NA PO NC
13D5:0000 B8D413 MOV AX,13D4
13C4:0000 09 1B 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13C4:0010 B8 E1 13 8E D8 A0 00 00-80 3E 00 00 0A 7E 09 B3 .........>...~.. 13C4:0020 04 F6 E3 A3 01 00 EB 17-80 3E 00 00 00 7C 09 B3 .........>...|.. 13C4:0030 03 F6 E3 A3 01 00 EB 07-B3 02 F6 E3 A3 01 00 B4 ................ 13C4:0040 4C CD 21 00 00 00 00 00-00 00 00 00 00 00 00 00 L.!............. 13C4:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 3-7、教材 习题 3.39
现有两个多字节压缩BCD码数9876543219H和12345671H,它们分别按低位字节在前高位字节在后存放在变量A1和 A2中,求它们的和与差,并将结果放在变量SUM和DEF中。
DATAS SEGMENT
A1 DB 19H,32H,54H,76H,98H A2 DB 91H,78H,56H,34H,12H SUM DB ?,?,?,?,?
DEF DB ?,?,?,?,?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码 STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX LEA BX,SUM LEA SI,A1 LEA DI,A2 MOV CL,5 CLC;CF=0
NEXT1: MOV AL,[SI] MOV AH,[DI] ADC AL,AH DAA
MOV [BX],AL INC SI INC DI INC BX DEC CL
JNZ NEXT1;此处输入代码段代码 LEA BX,DEF LEA SI,A1 LEA DI,A2 MOV CL,5 CLC;CF=0
NEXT2: MOV AL,[SI] MOV AH,[DI] SBB AL,AH DAS
MOV [BX],AL INC SI INC DI INC BX DEC CL
JNZ NEXT2;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS END START
13E3:003E 43 INC BX 13E3:003F FEC9 DEC CL -U
13E3:0041 75F0 JNZ 0033 13E3:0043 B44C MOV AH,4C 13E3:0045 CD21 INT 21
13E3:0047 0000 ADD [BX+SI],AL 13E3:0049 0000 ADD [BX+SI],AL 13E3:004B 0000 ADD [BX+SI],AL 13E3:004D 0000 ADD [BX+SI],AL 13E3:004F 0000 ADD [BX+SI],AL 13E3:0051 0000 ADD [BX+SI],AL 13E3:0053 0000 ADD [BX+SI],AL 13E3:0055 0000 ADD [BX+SI],AL 13E3:0057 0000 ADD [BX+SI],AL 13E3:0059 0000 ADD [BX+SI],AL 13E3:005B 0000 ADD [BX+SI],AL 13E3:005D 0000 ADD [BX+SI],AL 13E3:005F 0000 ADD [BX+SI],AL -G=0000 0043
AX=1286 BX=0014 CX=0000 DX=0000 SP=0000 BP=0000 SI=0005 DI=000A DS=13E1 ES=13D1 SS=13E1 CS=13E3 IP=0043 NV UP EI PL ZR NA PE NC 13E3:0043 B44C MOV AH,4C -DDS:0000
13E1:0000 19 32 54 76 98 91 78 56-34 12 10 11 11 11 11 28 .2Tv..xV4......( 13E1:0010 53 97 41 86 00 00 00 00-00 00 00 00 00 00 00 00 S.A............. 13E1:0020 B8 E1 13 8E D8 8D 1E 0A-00 8D 36 00 00 8D 3E 05 ..........6...>. 13E1:0030 00 B1 05 F8 8A 04 8A 25-12 C4 27 88 07 46 47 43 .......%..'..FGC 13E1:0040 FE C9 75 F0 8D 1E 0F 00-8D 36 00 00 8D 3E 05 00 ..u......6...>.. 13E1:0050 B1 05 F8 8A 04 8A 25 1A-C4 2F 88 07 46 47 43 FE ......%../..FGC. 13E1:0060 C9 75 F0 B4 4C CD 21 00-00 00 00 00 00 00 00 00 .u..L.!......... 13E1:0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 3-8、教材 习题 3.43
在数据段中有一个字节数组,编程统计其中正数的个数,放入A单元,负数的个数,放入B单元。
DATAS SEGMENT
TABLE DB 23,2,1,,-4,-35,-3,7,5, A DB ?
B DB ?;此处输入数据段代码 DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS START:
MOV AX,DATAS MOV DS,AX LEA SI,TABLE MOV CL,10 A2: MOV AL,[SI] TEST AL,80H JNZ A1 INC CH
JMP DONE A1: INC DL DONE:INC SI DEC CL JNZ A2 MOV A,CH
MOV B,DL ;此处输入代码段代码 MOV AH,4CH INT 21H CODES ENDS END START
-U
13E2:0000 B8E113 MOV AX,13E1 13E2:0003 8ED8 MOV DS,AX
13E2:0005 8D360000 LEA SI,[0000] 13E2:0009 B10A MOV CL,0A 13E2:000B 8A04 MOV AL,[SI] 13E2:000D A880 TEST AL,80 13E2:000F 7504 JNZ 0015 13E2:0011 FEC5 INC CH 13E2:0013 EB02 JMP 0017 13E2:0015 FEC2 INC DL 13E2:0017 46 INC SI 13E2:0018 FEC9 DEC CL 13E2:001A 75EF JNZ 000B 13E2:001C 882E0A00 MOV [000A],CH -U
13E2:0020 88160B00 MOV [000B],DL 13E2:0024 B44C MOV AH,4C 13E2:0026 CD21 INT 21
-G=0000 0024
AX=1359 BX=0000 CX=0700 DX=0003 SP=0000 BP=0000 SI=000A DI=0000 DS=13E1 ES=13D1 SS=13E1 CS=13E2 IP=0024 NV UP EI PL ZR NA PE NC 13E2:0024 B44C MOV AH,4C
-DDS:0000
13E1:0000 17 02 01 40 FC DD FD 07-05 59 07 03 00 00 00 00 ...@.....Y...... 13E1:0010 B8 E1 13 8E D8 8D 36 00-00 B1 0A 8A 04 A8 80 75 ......6........u 13E1:0020 04 FE C5 EB 02 FE C2 46-FE C9 75 EF 88 2E 0A 00 .......F..u..... 13E1:0030 88 16 0B 00 B4 4C CD 21-00 00 00 00 00 00 00 00 .....L.!........ 13E1:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13E1:0060 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- gamedaodao.com 版权所有 湘ICP备2022005869号-6
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务