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

(5)TEST DH,0FH (DH)=18H CF=0 (6)CMP CX,00H (CX)=0004H CF=0 (7)SHR DX,CL (DX)=0186H CF=0 (8)SAR AL,1 (AL)=04H CF=0 (9)SHL BH,CL (BH)=0F0H CF=0 (10)SAL AX,1 (AX)=4A10H CF=0

(11)RCL BX,1 CF=1,(BX)=1E6DH, CF=0,(BX)=1E6CH CF=0 (12)ROR DX,CL (DX)=4186H CF=0 11. 假设数据定义如下: DATA SEGMENT

STRING DB ‘The Personal Computer & TV’ DATA ENDS

试用字符串操作指令编程完成以下功能:

(1)把该字符串传送到附加段中偏移地址为GET_CHAR开始的内存单元中。 解:程序段如下:

LEA SI,STRING ;置源串偏移地址 LEA DI,GET_CHAR;置目的串偏移地址 MOV CX,26;置串长度

CLD ;方向标志复位 REP MOVSB ;字符串传送

12.编程将AX寄存器中的内容以相反的次序传送到DX寄存器中,并要求AX中的内容不被破坏,然后统计DX寄存器中1的个数是多少。

解:将AX的内容用ROR循环右移,16次之后AX的内容不变(如果用算术/逻辑右移SHL/SAL,则AX的内容破坏,需要用堆栈PUSHU AX/POP AX保护),其最低位移入CF中,再使用RCL循环左移将CF中的值移入DX中。并且,如果CF的值为1,则将BL加1。

MOV CX, 16 XOR BL, BL

LP1: ROR AX, 1

JNC LP2 INC BL

LP2: RCL DX,1

LOOP LP1 HLT

调试程序:

STACK SEGMENT STACK

DB 100 DUP(?) STACK ENDS DATA SEGMENT BUF DW 12

BUF1 DW 100 DUP (?) DATA ENDS CODE SEGMENT

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

MOV AX,DATA

MOV DS,AX MOV AX,1234H MOV CX, 16 XOR BL, BL

LP1: ROR AX, 1 JNC LP2 INC BL LP2: RCL DX,1 LOOP LP1 HLT CODE ENDS

END START

15. 某班有七个同学的英语成绩低于80分,分数存在ARRAY数组中,试编程完成以下工作:给每人加5分,结果存到NEW数组中. 解:

STACK SEGMENT STACK

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

NEW DB 7 DUP(?) DATA ENDS CODE SEGMENT

ASSUME CS:CODE,DS:DATA,SS:STACK START:MOV CX, 7 MOV BX, 0

LP1: MOV AL, ARRAY[BX] ADD AL, 05H DAA

MOV NEW[BXI], AL INC BX LOOP LP1 HLT CODE ENDS

END START 调试程序:

STACK SEGMENT STACK

DB 100 DUP(?) STACK ENDS DATA SEGMENT

ARRAY DB 65H,76H,78H,54H,90H,85H,68H NEW DB 7 DUP(?) BUF1 DW 100 DUP (?)

DATA ENDS CODE SEGMENT

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

MOV AX,DATA

MOV DS,AX MOV CX, 7 MOV BX, 0

LP1: MOV AL, ARRAY[BX] ADD AL, 05H DAA

MOV NEW[BXI], AL INC BX LOOP LP1 HLT CODE ENDS

END START

(1)给每人加5分,结果存到NEW数组中 (2)把总分存到SUM单元中 (3)把平均分存到AVERAGE单元中 解:

STACK SEGMENT STACK

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

NEW DB 7 DUP(?) SUM DW 0 AVG DB 0 DATA ENDS CODE SEGMENT

ASSUME CS:CODE,DS:DATA,SS:STACK START:MOV CX, 7 MOV SI, 0 MOV SUM, 0 MOV AH, 0 LP1: MOV AL, ARRAY[SI] ADD AL, 05H DAA

MOV NEW[SI], AL ADD AL ,SUM DAA

MOV SUM,AL

某班有七个同学的英语成绩低于80分,分数存在ARRAY数组中,试编程完成以下工作:

ADC AH, 0 DAA

MOV SUM+1, AH INC SI LOOP LP1

MOV AX, SUM MOV BL,07H DIV BL MOV AVG, AL HLT CODE ENDS

END START 调试程序:

STACK SEGMENT STACK

DB 100 DUP(?) STACK ENDS DATA SEGMENT

ARRAY DB 65H,76H,78H,54H,90H,85H,68H NEW DB 7 DUP(?) SUM DB 00H,00H AVG DB 0

BUF1 DW 100 DUP (?) DATA ENDS CODE SEGMENT

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

MOV AX,DATA

MOV DS,AX MOV CX, 7 MOV SI, 0 MOV SUM, 0 MOV AH, 0 LP1: MOV AL, ARRAY[SI] ADD AL, 05H DAA

MOV NEW[SI], AL ADD AL , SUM DAA

MOV SUM,AL ADC AH, 0 MOV SUM+1, AH INC SI LOOP LP1 MOV AL, SUM

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4