IBM-PC汇编语言程序设计(第二版)课后习题答案(清华大学出版社)(沈美明,温冬蝉著)第七章答案
2006-11-04 22:03
1       答: CLRB MACRO N, ARRAY
CLD
MOV CX, N
MOV AL, 20H
LEA DI, ARRAY
REP STOSB
ENDM

2
、答:

WAGES MACRO RATE
HOUR
MOV AL
RATE
MOV BL
HOUR
MUL BL
;计算周工资


ADD AX
AX
ADD AX
AX ;一个月有 4


MOV WAG
AX ;暂存中间结果


ADD BL
BL
ADD BL
BL ;计算月出工小时数


MOV AL
BL
MOV AH
0
MOV BL
10
DIV BL
MOV BL
3
MUL BL
;计算奖金

ADD WAG
AX ;计算工资总数

ENDM
宏展开:

1 MOV AL
R1
1 MOV BL
42
1 MUL BL
1 ADD AX
AX
1 ADD AX
AX
1 MOV WAG
AX
1 ADD BL
BL
1 ADD BL
BL
1 MOV AL
BL
1 MOV AH
0
1 MOV BL
10
1 DIV BL
1 MOV BL
3
1 MUL BL
1 ADD WAG
AX


3
、答:

(1)
调用有效
1 PUSH AX
2 MOV AX, P1
2 SUB AX, P2
1 CMP AX, 0
1 JGE ??0000
1 NEG AX
1 ??0000: MOV DISTANCE, AX
1 POP AX
(2)
调用有效
1 PUSH AX
2 MOV AX, [BX]
2 SUB AX, [SI]
1 CMP AX, 0
1 JGE ??0001
1 NEG AX
1 ??0001: MOV X[DI], AX
1 POP AX
(3)
调用无效,有错误指令

1 ??0002: MOV 240H, AX
(4)
调用有效,但无意义

宏展开略。



4
、答:

SEND MACRO SCHARS, DCHARS
LOCAL NEXT, EXIT
PUSH AX
PUSH SI
MOV SI, 0
NEXT: MOV AL, SCHARS[SI]
MOV DCHARS[SI], AL
CMP AL, 24H
JZ EXIT
INC SI
JMP NEXT
EXIT: POP SI
POP AX
ENDM


5
、答:

BIN_SUB MACRO OPERAND
COUNT
RESULT
LOCAL NEXT
LEA BX
OPERAND
MOV CX
COUNT
DEC CX
MOV AL
[BX]
NEXT
INC BX
SUB AL
[BX]
LOOP NEXT
MOV RESULT
AL
ENDM


7
、答:

宏展开:

2 DATA0 DW

2 DATA1 DW



9
、答:

1 MOV TAB , 0
1 MOV TAB+1, 1
1 MOV TAB+2, 2
1 MOV TAB+3, 3
1 MOV TAB+4, 4
1 MOV TAB+5, 5
1 MOV TAB+6, 6


10
、答:

STORE MACRO X
IRPC X, 0123456
MOV TAB+&X, X
ENDM
ENDM

12
、答:

FINSUM MACRO X
Y
SUM
MOV AX, X
MOV BX, Y
.IF AX > BX
ADD BX, BX
ADD AX, BX
MOV SUM, AX
.ELSE
ADD AX, AX
ADD AX, BX
MOV SUM, AX
.ENDIF
ENDM

14
、答:

DOS21 MACRO DOSFUNC
BUFF
IFNB áBUFF?
MOV AH,DOSFUNC
MOV DX,OFFSET BUFF
INT 21H
ELSE
MOV AH,DOSFUNC
INT 21H
ENDIF
ENDM
展开宏调用:

1 MOV AH,01
1 INT 21H
1 MOV AH,0AH
1 MOV DX,OFFSET IPFIELD
1 INT 21H