IDIV 汇编语言的问题 [英] Problems with IDIV Assembly Language
本文介绍了IDIV 汇编语言的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CX 等于 14AX 等于 16
CX is equal to 14 AX is equal to 16
IDIV CX
但不知为何在 AL 有 37 个.在该行之前没有错误或错误.我哪里做错了?谢谢!附言在 Emu8086 上写
But somewhy in AL there is 37. There is no mistakes or errors before that line. Where I've made a mistake? Thank you! p.s. writting on Emu8086
推荐答案
IDIV CX
将 32 位值 DX:AX
除以 CX
>,将商存入AX
,余数存入DX
.
IDIV CX
divides the 32-bit value DX:AX
by CX
, and stores the quotient in AX
and the remainder in DX
.
因此 IDIV
指令之前的 DX
的值很重要,您应该将 AX
符号扩展为 DX
使用 CWD
指令(在 IDIV
之前),或者使用 eg 清除 DX
XOR DX,DX
(在DIV
之前).
Therefore the value of DX
prior to the IDIV
instruction matters, and you should either sign-extend AX
into DX
using the CWD
instruction (before IDIV
), or clear DX
using e.g. XOR DX,DX
(before DIV
).
这篇关于IDIV 汇编语言的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文