-2

We have a bootloader, and we have a program, the program is asserting 0 to register RAX. After that with DIV command, divides the register RAX by himself.

And of course bootloader loads the program.

I know any assembler give an error in this status, but the program is raw binary. So we can easily write this program with a hex editor because of the program consisting from only 2 instructions.

What happens in this status?

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
Ibrahim Ipek
  • 479
  • 4
  • 13

1 Answers1

-3

According to book Intel® 64 and IA-32 Architectures Software Developer’s Manual:

The processor reports the divide-by-zero exception whenever an instruction attempts to divide a finite non-zero operand by 0. The masked response for the divide-by-zero exception is to set the ZE flag and return an infinity signed with the exclusive OR of the sign of the operands. If the divide-by-zero exception is not masked, the ZE flag is set, a software exception handler is invoked, and the operands remain unaltered.


So, we have flag for that. When we try to do this, this flag will modified and value of the accumulator register will not chance.

Ibrahim Ipek
  • 479
  • 4
  • 13
  • 3
    That's what happens with when a floating point instruction divides by zero. It doesn't apply to the DIV instruction. – Ross Ridge Aug 26 '16 at 18:21