2

I'm trying to understand how the division instruction in FASM works.

If I get it right then it expects the value to divide in the register (e)dx and (e)ax. See accepted answer here: Assembly Language - How to Do Modulo?

After the operation the result is stored in (e)ax. The remainder is stored in (e)dx.

But what happens if I divide a very large number with a very tiny divisor?

Let's say I would store 2 exp. 64 in edx:eax. Then divide it by a number <= 1 . Then the result would be something >= 2 exp. 64 ...

How could that work?

The result wouldn't fit into eax alone.

Can someone help me to understand the issue?

Community
  • 1
  • 1
cluster1
  • 4,968
  • 6
  • 32
  • 49
  • 4
    2^64 doesn't fit in the 64-bit edx:eax register pair. And unless you're talking about negative numbers, the only unsigned integers <= 1 are 1 and 0. Division by zero always raises #DE, and so does any division where the quotient doesn't fit in the destination register, as explained in the [insn ref manual](http://www.felixcloutier.com/x86/DIV.html). See also http://stackoverflow.com/questions/37262572/on-which-platforms-does-integer-divide-by-zero-trigger-a-floating-point-exceptio for more about #DE and what OSes do in response. (e.g. POSIX OSes deliver SIGFPE.) – Peter Cordes Nov 28 '16 at 09:58
  • Thanks. Helped me already to understand it better ... – cluster1 Nov 28 '16 at 10:06

0 Answers0