在x86 Assembly中分割64位的问题 [英] Problems dividing 64 bits in x86 Assembly

查看:102
本文介绍了在x86 Assembly中分割64位的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在x86 Assembly中分割时,我不断收到程序收到信号SIGFPE,算术异常。这很令人困惑,因为如果我除以10,答案应该小于64位答案。...

  mov $ 0x82b40000, $ eax 
mov $ 0x21c3677c,$ edx
mov $ 10000000,%ebx
div%ebx


解决方案

算术异常为整数溢出,来自 #DE 硬件除法异常!
这是正常现象或预期结果,因为结果大于32位数字。


请记住:64位/ 32位除法的商只是一个32位寄存器(EAX)。 EDX输出是余数,不是商的一半。 div%ebx 的操作数大小为32位;


英特尔的数据表中有一个有用的表:



I keep getting 'Program received signal SIGFPE, Arithmetic exception' when dividing in x86 Assembly. It's confusing because the answer should be smaller than a 64 bit answer if I divide by 10....

mov $0x82b40000, $eax
mov $0x21c3677c, $edx
mov $10000000, %ebx
div %ebx

解决方案

The arithmetic exception is "Integer overflow", from the #DE hardware divide exception! Which is normal or expected, because your result is bigger than 32-bit number.

Remember: the quotient of 64 bit / 32-bit division is only a 32 bit register (EAX). The EDX output is the remainder, not high half of the quotient. The operand-size of div %ebx is 32-bit; only the dividend is 64-bit.

Intel's datasheet has a useful table:

这篇关于在x86 Assembly中分割64位的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆