Assembly units and floating points

  mov eax, 0x01
  mov ecx, 0x02
  div ecx                 ; Divide AX/CX, saves remainder in DX
  cmp dx, 0
  je OddNumber
  int 80h

When I try to split 1/2, instead of calling OddNumber, it returns a Floating Point Exception. I know 1/2 is floating, but how can I handle this? Thank.

GDB says: "Received SIGFPE signal, arithmetic exception." by the way.

+5
source share
2 answers
  • Before calling, div ecxyou must perform a null value edx. When using a 32-bit divider (for example, ecx), it divdivides the 64-bit value into edx:eaxby its argument, therefore, if edxthere is an undesirable file in, it is considered as part of the dividend.

  • div , , edx, dx.

+10

, , 0. , edx div?

+1

All Articles