《微型计算机原理与接口技术》第三版 杨立著 课后习题答案
发布网友
发布时间:2023-07-20 02:48
我来回答
共1个回答
热心网友
时间:2023-12-31 04:40
微型计算机原理与接*术第三章习题
一、选择 CBC AAD
三、判断 √√√√√
五、设计
1、编程实现求S=(X2+Y2)/Z的值,将最后结果放入RESULT单元保存。
参考程序如下:
DATA SEGMENT ;定义数据段
X DB 5 ;给X、Y、Z赋初值
Y DB 7
Z DB 2
RESULT DB ? ;定义RESULT单元,预留空间
DATA ENDS ;数据段结束
CODE SEGMENT ;定义代码段
ASSSUME CS:CODE,DS:DATA
START:MOV AX,DATA ;初始化DS
MOV DS,AX
MOV AL,X ;将数据X送AL
MUL X ;计算X2
MOV BX,AX ;将中间结果保存到BX
MOV AL,Y ;将数据Y送AL
MUL Y ;计算Y2
ADD AX,BX ;X2+Y2,结果保存到AX
DIV Z ;计算(X2+Y2)/Z
MOV RESULT,AL ;最后结果送RESULT单元
MOV AH,4CH ;返回DOS
INT 21H
CODE ENDS ;代码段结束
END START ;汇编结束
2.计算S=(A+B)/2 – 2(A AND B)。
DATA SEGMENT
A DB 12
B DB 51
S DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AL,A
ADD AL,B
SHR AL,1
MOV AH,A
MOV BL,B
AND AH,BL
MOV BL,AH
SHL BL,1
SUB AL,BL
MOV S,AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
3. 参考P86 例4.3
4.
DATA SEGMENT
X DW 34
S DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV AX,X
CMP AX,0
JL DOUB
CMP AX,10
JLE TRIB
SAL AX,1
SAL AX,1
JMP EXIT
DOUB: SAL,AX,1
JMP EXIT
TRIB: SAL AX,1
ADD AX,X
EXIT: MOV S,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
5.统计非数字字符的个数
DATA SEGMENT
BUF DB 20H DUP (?)
CNT DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,BUF
MOV DL,0
NEXT1: MOV AH,01H
INT 21H
MOV [SI],AL
INC SI
CMP AL,0DH
JZ EXIT
CMP AL,30H
JGE NEXT
INC DL
JMP NEXT1
NEXT: CMP AL,39H
JBE NEXT1
INC DL
JMP NEXT1
EXIT: MOV CNT,DL
MOV AH,4CH
INT 21H
CODE ENDS
END START
6、将键盘连续输入的小写字母转换成大写字母
CODE SEGMENT
ASSUME CS:CODE
START: MOV AH,01H
INT 21H
MOV BL,AL
MOV DL,’-‘
MOV AH,02H
INT 21H
MOV AL,BL
CMP AL,’a’
JB EXIT
CMP AL,’z’
JA EXIT
SUB AL,20H
MOV DL,AL
MOV AH,02H
INT 21H
MOV DL,0AH
MOV AH,02H
INT 21H
MOV DL,0DH
MOV AH,02H
INT 21H
JMP START
EXIT: MOV AH,4CH
INT 21H
CODE ENDS
END START
7. 统计负数的个数
DATA SEGMENT
BUF DB 45,50,-34,40,4,15,29,-1,-2,-59
CN EQU $-buf
A DB ?
B DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI, BUF
MOV CX, CN
MOV BX, 0
LP: MOV AL, [SI]
INC SI
TEST AL, 80H
JZ NEXT
INC BH
JMP EXIT
NEXT: INC BL
EXIT: LOOP LP
MOV A, BL
MOV B, BH
MOV AH,4CH
INT 21H
CODE ENDS
END START
8、宏定义,将16进制数转换成ASCII码
HEXTOA MACRO
AND AL,0FH
COM AL,9
JNA HEXTOA1
ADD AL,07H
HEXTOA1: ADD AL,30H
ENDM