据我了解,IDIV 将商存储在 AX 寄存器中,将余数存储在 DX 寄存器中,但由于某种原因,DX 中的值不是余数的正确值。
EX:(9/5=1.8)如果我错了,请纠正我,但 DX 寄存器不是保持值 8 吗?
这是我的代码:
.MODEL SMALL,BASIC,FARSTACK
EXTRN GETDEC:FAR
EXTRN PUTDEC:FAR
EXTRN PUTSTRNG:FAR
.STACK 256
.CONST
PROMPT DB 'ENTER SIGNED NUMBER '
ANNOTATION DB 'VALUE: '
.CODE
code:
MOV AX,SEG DGROUP
MOV ES,AX
LEA DI,PROMPT
MOV CX,22
CALL PUTSTRNG
CALL GETDEC
;I just enter 1 so AX=1 but the code is used for solving simple arithmetic problems (decimal * 9/5)
MOV BX,9
IMUL BX
MOV BX,5
IDIV BX
MOV AX,DX ;Right here is where I check what's inside DX, I get a value of 4
not 8
LEA DI,ANNOTATION
MOV CX,22
CALL PUTSTRNG
MOV BH,0
CALL PUTDEC
.EXIT
END code
任何帮助,将不胜感激。