IBM-PC汇编语言程序设计(第二版)课后习题答案(清华大学出版社)(沈美明,温冬蝉著)第十章答案
2006-11-04 22:05
IBM-PC汇编语言程序设计(第二版)

1 。答:
1 EXYRN SUBPRO FAR 2
PUBLIC SUBPRO

2
、答:

1
PUBLIC QTY, VALUE, PRICE
2
EXTRN QTY:BYTE, VALUE:WORD, PRICE:WORD


3
、答:

模块 1

PUBLIC VAR1, VAR2, LAB3
模块
2:
PUBLIC VAR3, LAB2
EXTRN VAR1:DWORD, VAR2:BYTE, LAB1:NEAR, LAB3:FAR
模块
3:
PUBLIC LAB3
EXTRN VAR1:DWORD, VAR2:BYTE, LAB1:NEAR, LAB2:FAR

4
、答:

EXTRN SUBMUL:FAR
SSEG SEGMENT
DW 64 DUP(?)
SSEG ENDS
;--------------------------------------------
DSEG SEGMENT
QTY DW ?
PRICE DW ?
DSEG ENDS
;---------------------------------------------
CSEG1 SEGMENT
ASSUME CS:CSEG1, DS:DSEG, SS:SSEG
CALLMUL PROC FAR
MOV AX, DSEG
MOV DS,AX
MOV AX, PRICE
MOV BX, QTY
CALL FAR PTR SUBMUL

CALLMUL ENDP
CSEG1 ENDS
END CALLMUL
;------------------------------------------------
PUBLIC SUBMUL
CSEG2 SEGMENT
ASSUME CS:CSEG2
SUBMUL PROC FAR
MUL BX
RET
SUBMUL ENDP
CSEG2 ENDS
END
;--------------------------------------------------





5
、答:

1 D_SEG SEGMENT
2 X DW 16 DUP(?)
3 Y DW 16 DUP(?)
4 D_SEG ENDS
;--------------------------------------------
5 E_SEG SEGMENT
6 R DW 16 DUP(?)
7 E_SEG ENDS
;---------------------------------------------
8 C_SEG SEGMENT
9 ASSUME CS:C_SEG, DS:D_SEG, ES:E_SEG
10 MAIN PROC FAR
11 MOV AX, D_SEG
12 MOV DS,AX
13 MOV AX, E_SEG
14 MOV ES, AX
15 CALL COMPUTE
16 …
17 MAIN ENDP
;------------------------------------------------
18 COMPUTE PROC NEAR
19 MOV CX,16
20 MOV SI,0
21 MOV DI,0
22 MOV BX,0
23 NEXT: MOV AX, X[SI]
24 ADD AX, Y[DI]
25 SUB AX, 3
26 MOV ES:R[BX],AX
27 INC SI
28 INC DI
29 INC BX
30 LOOP NEXT
31 RET
32 COMPUTE ENDP
33 C_SEG ENDS
;---------------------------------------------------
34 END MAIN

(1) D_SEG SEGMENT

D_SEG ENDS
;----------------------------------------
E_SEG SEGMENT

E_SEG ENDS
;---------------------------------------
C_SEG1 SEGMENT
ASSUME CS:C_SEG, DS:D_SEG, ES:E_SEG
MAIN PROC FAR
MOV AX, D_SEG
MOV DS,AX
MOV AX, E_SEG
MOV ES, AX
CALL FAR PTR COMPUTE

MAIN ENDP
C_SEG1 ENDS
;------------------------------------------------
C_SEG2 SEGMENT
ASSUME CS:C_SEG2, DS:D_SEG, ES:E_SEG
COMPUTE PROC FAR

COMPUTE ENDP
C_SEG2 ENDS
;--------------------------------------------------
END MAIN

(2) D_SEG SEGMENT

D_SEG ENDS
;----------------------------------------
E_SEG SEGMENT

E_SEG ENDS
;---------------------------------------
EXTRN COMPUTE:FAR
PUBLIC X, Y, R
C_SEG1 SEGMENT
ASSUME CS:C_SEG, DS:D_SEG, ES:E_SEG
MAIN PROC FAR
MOV AX, D_SEG
MOV DS,AX
MOV AX, E_SEG
MOV ES, AX
CALL FAR PTR COMPUTE

MAIN ENDP
C_SEG1 ENDS
END MAIN
;--------------------------------------------------
EXTRN X:WORD, Y:WORD, R:WORD
PUBLIC COMPUTE
C_SEG2 SEGMENT
ASSUME CS:C_SEG2, DS:D_SEG, ES:E_SEG
COMPUTE PROC FAR
MOV AX, D_SEG
MOV DS,AX
MOV AX, E_SEG
MOV ES, AX

COMPUTE ENDP
C_SEG2 ENDS
END
;--------------------------------------------------


6
、答:

.model small
.stack 100h
.data
public
data1 dw 1228
data2 dw 52400
result dd ?
quotient dw ?
remainder dw ?
.code
extrn dmul:far,ddiv:far
start: mov ax,@data
mov ds,ax
mov dx, data1
mov ax, data2
push ax
push dx
call far ptr dmul
call far ptr ddiv
mov ah,4ch
int 21h
end start
;----------------------------------------------
.model small
extrn result:dword
.code
public dmul
dmul proc far_ _
push bp
mov bp,sp
mov ax,[bp+6]
mov bx,[bp+8]
mul bx
mov word ptr result,ax
mov word ptr result+2,dx
pop bp
ret
dmul endp
end
;---------------------------------------------------
.model small
extrn quotient:word, remainder:word
.code
public ddiv
ddiv proc far_ _
push bp
mov bp,sp
mov bx,[bp+6]
mov ax,[bp+8]
mov dx,0
div bx
mov quotient,ax
mov remainder,dx
pop bp
ret
dmul endp
end