Problems dividing 64 bits in x86 Assembly

后端 未结 2 1337
遇见更好的自我
遇见更好的自我 2021-01-16 16:56

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 ans

2条回答
  •  既然无缘
    2021-01-16 17:31

    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:

    enter image description here

提交回复
热议问题