《微机原理与接口技术》(第四版)周何琴课后习题答案

DB 99H, 89H, 79H, 69H,75H,85H,63H,73H,83H,93H SUM DW 0 AVER DB 0

BUF DB 100 DUP (?) DATA ENDS CODE SEGMENT

ASSUME CS:CODE,DS:DATA,SS:STACK START: PUSH DS MOV AX,DATA MOV DS,AX

MOV DI, OFFSET LIST MOV BX, 19 LP0: MOV SI, DI MOV CX, BX LP1: MOV AL, [SI] INC SI

CMP AL, [SI] JNC LP2 MOV DL, [SI] MOV [SI-1], DL MOV [SI], AL LP2: LOOP LP1 DEC BX JNZ LP0 LP3: MOV CX, 20

MOV BX, OFFSET LIST MOV SUM, 0 XOR AX, AX LP4: ADD AL, [BX] DAA ADC AH, 0 INC BX LOOP LP4 MOV SUM, AX MOV BL, 20H DIV BL ADD AL,0 DAA

MOV AVER AL POP DS HLT CODE ENDS END START

17

20. 编程将存放在AL中的无符号二进制数,转化成十六进制数,再转换成ASII码并显示在屏幕上。 解: 程序如下:

STACK SEGMENT STACK DB 100 DUP(?) STACK ENDS DATA SEGMENT DB 100 DUP(?) DATA ENDS CODE SEGMENT

ASSUME CS:CODE, DS:DATA, SS:STACK START: PUSH DS MOV AX, DATA MOV DS, AX MOV DH, AL MOV CH, 02H ST1: MOV CL, 4 ROR DH, CL MOV AL, DH AND AL, 0FH ADD AL, 30H CMP AL, 39H JBE DISP ADD AL, 07H DISP: MOV DL, AL MOV AH, 02H INT 21H DEC CH JNZ ST1 POP DS MOV AH, 4CH INT 21H HLT CODE ENDS END START

调试程序如下:

STACK SEGMENT STACK BUF DB 01111000B

DB 100 DUP(?) STACK ENDS DATA SEGMENT DB 100 DUP(?)

18

DATA ENDS CODE SEGMENT

ASSUME CS:CODE, DS:DATA, SS:STACK START: PUSH DS MOV AX, DATA MOV DS, AX MOV AL, BUF MOV DH, AL MOV CH, 02H ST1: MOV CL, 4 ROR DH, CL MOV AL, DH AND AL, 0FH ADD AL, 30H CMP AL, 39H JBE DISP ADD AL, 07H DISP: MOV DL, AL MOV AH, 02H INT 21H DEC CH JNZ ST1 POP DS MOV AH, 4CH INT 21H HLT CODE ENDS END START

21. 编写程序,使用三种以上的方法,将存储器中2000H开始的地址单元中的100字节数据复制到3000H开始的存储器地址单元中。

解:

(1)利用通用传送指令MOV

MOV SI,2000H 注意这里如果是标号地址 ,则必须用OFFSET MOV DI,3000H MOV CX,100 LP1: MOV AL,[SI]

MOV [DI],AL INC SI INC DI

LOOP LP1 HLT

MOV CX,100 MOV BX,0

LP0:MOV AL,2000[BX]

MOV 3000[BX],AL INC BX

19

LOOP LP0 HLT

(2)利用交换指令XCHG MOV SI,2000H MOV DI,3000H MOV CX,100 LP2: MOV AL,[SI]

XCHG [DI],AL INC SI INC DI

LOOP LP2 HLT

(3)利用换码指令XLAT MOV BX,2000H MOV DI,3000H MOV CX,100

LP3: XOR AL,AL

XLAT

MOV [DI], AL INC BX INC DI LOOP LP3 HLT

(4)利用堆栈实现数据传送 MOV SI,2000H MOV DI,3000H MOV CX,50 LP4: PUSH [SI]

POP [DI] INC SI INC SI INC DI INC DI

LOOP LP4 HLT

(5)利用串操作指令REP MOVSB

MOV SI,2000H MOV DI,3000H MOV CX,100

CLD ;DF=0,SI、DI自动+1 REP MOVSB HLT 调试程序:

STACK SEGMENT STACK DB 100 DUP(?) STACK ENDS DATA SEGMENT ORG 2000H

DB 11H,22H,33H,44H,55H.66H,77H,88H,99H DB 100 DUP(?) ORG 3000H

DB 100 DUP(?) DATA ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DATA,SS:STACK

20

联系客服:779662525#qq.com(#替换为@)