本文介绍了EMU8086 将 32 位数字除以 16 位数字给出意外的 0 余数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 emu8086 工具将(无符号)8A32F4D5 除以 C9A5.我预计商为 AF73H,余数为 94B6H.编写以下代码后,我得到了正确的商数,但余数变为 0000h.我错过了什么吗?

.MODEL 小.堆栈 100 小时.数据.代码主程序;初始化DS移动轴,@DATAMOV DS,AX;在此处输入您的代码MOV DX, 8A32HMOV AX, 0F4D5HMOV BX, 0C9A5HDIV BX;退出到DOSMOV AX,4C00HINT 21H主终端结束主要

EMU8086 中的输出:

解决方案

这看起来像是 EMU8086 中的一个错误.这个无符号除法没有被零除,也没有溢出(

如果使用 IDIV 指令对除法进行签名,它将产生除以零异常因为除法溢出.

I was trying to divide (Unsigned) 8A32F4D5 by C9A5 using emu8086 tool. I expected the quotient to be AF73H and the remainder be 94B6H. After writing the following code, I was getting correct quotient but the remainder became 0000h. Am I missing something?

.MODEL SMALL
.STACK 100H
.DATA
.CODE

MAIN PROC
; initialize DS
MOV AX,@DATA
MOV DS,AX
; enter your code here
MOV DX, 8A32H
MOV AX, 0F4D5H
MOV BX, 0C9A5H

DIV BX

;exit to DOS

MOV AX,4C00H
INT 21H

MAIN ENDP
    END MAIN

The output in EMU8086:

解决方案

This looks like a bug in EMU8086. There is no division by zero nor is there an overflow with this unsigned division (DIV). You are correct that 0x8A32F4D5 divided by 0xC9A5 has a remainder of 0x94B6. To verify this I ran this code with Turbo Debugger in DOSBOX and got the expected results:

Had this been signed division using the IDIV instruction it would produce a division by zero exception because of division overflow.

这篇关于EMU8086 将 32 位数字除以 16 位数字给出意外的 0 余数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 00:01