汇编语言计算 (X+(Y*Z-100)/W
发布网友
发布时间:2022-04-29 18:28
我来回答
共2个回答
热心网友
时间:2022-06-19 02:20
CODE SEGMENT
ASSUME CS:CODE
ORG 100H
START:
PUSH CS
POP DS
PUSH CS
POP ES
MOV AX,Y
MOV BX,Z
IMUL BX
SUB AX,100
SBB DX,0
MOV BX,W
IDIV BX
MOV BX,X
ADD AX,BX
CALL DISPAX
MOV AH,4CH
INT 21H
X DW 100
Y DW 2000
Z DW 3000
W DW 400
;X+(Y*Z-100)/W
DISPAX PROC NEAR
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DS
PUSH CS
POP DS
MOV BYTE PTR NZ,0
PUSH AX
LEA SI,DIVARR
MOV CX,5
@1:
POP AX
MOV DX,0
MOV BX,[SI]
DIV BX
PUSH DX
CMP AL,0
JNE @2
CMP BYTE PTR NZ,1
JE @2
CMP CX,1
JE @2
MOV DL,20H
JMP @3
@2:
ADD AL,30H
MOV DL,AL
MOV BYTE PTR NZ,1
@3:
MOV AH,2
INT 21H
INC SI
INC SI
LOOP @1
POP DX
POP DS
POP SI
POP DX
POP CX
POP BX
RET
DIVARR DW 10000,1000,100,10,1
NZ DB 0
DISPAX ENDP
CODE ENDS
END START追答程序按带符号数编制且经调试运行无误
热心网友
时间:2022-06-19 02:20
dseg segment
X DW 123
Y DW 456
Z DW 789
W DW 234
R DW 0
dseg ends
cseg segment
assume cs:cseg, ds:dseg
start:
mov ax, dseg
mov ds, ax
mov ax,Y
mul Z
sub ax, 100
sbb dx, 0
add ax, X
adc dx, 0
div w
mov R,ax
mov ah,4ch
int 21h
cseg ends
end start