Floating point exception when dividing by x86 nasm

I am busy studying the Assembly and looked at the separation, however I came across a pickle with the following statement:

mov edx,0x00000001 mov eax,0x00000000 mov ecx,0x00000002 idiv ecx 

Gdb:

  0x08048071 <+17>: mov edx,0x1 0x08048076 <+22>: mov eax,0x0 0x0804807b <+27>: mov ecx,0x2 => 0x08048080 <+32>: idiv ecx 

I wanted to split 0x100000000 by 0x00000002, since the range for splitting EDX: EAX I moved 0x1 to EDX and 0x0 to EAX. Then I move 0x2 to ECX and dividing, this unfortunately gives me a floating point exception, I'm not sure what I did wrong.

When using a div (unsigned), it works fine, so I'm wondering what is the difference in interpretation between div and idiv for this particular statement that throws an exception.

+8
assembly x86 linux nasm
source share
1 answer

The factor ( 0x80000000 ) does not fit into a 32-bit signed integer (maximum value: 0x7fffffff ). Therefore, you get an exception. It fits into an unsigned 32-bit integer (maximum value is 0xffffffff ), so no exception is thrown unsigned.

+7
source share

All Articles