微机原理与接口技术周何琴课后习题答案 - 图文 下载本文

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 AVERAL POP DS HLT CODE ENDS 解: 程序如下:

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

END START

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

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(?) 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 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 START:PUSH DS MOV AX,DATA MOV DS,AX MOV SI,2000H MOV DI,3000H MOV CX,100 LP1: MOV AL,[SI] MOV [DI],AL INC SI

INC DI

LOOP LP1 POP DS HLT CODE ENDS END START

22. 在DATA开始的4个单元中存放着一个32位数,求出其中的“1”的个数,并存入COUNT单元中。

解: DATA SEGMENT DATA1 DB 0FEH,86H,7CH,35H COUNT DB 00H DATA ENDS STACK SEGMENT

DB 100 DUP(?)

STACK ENDS CODE SEGMENT

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

MOV AX,DATA

MOV DS,AX MOV AX,STACK MOV SS,AX MOV SI,OFFSET DATA1 MOV BX,[SI] MOV DX,[SI+2] MOV CX,32 XOR AL,AL LP1:RCR DX,1