I am trying to run the following code in assembly:
mov %si, %ax
mov $15, %si
div %si
mov %eax, %esi
When I make my program, it compiles, but at runtime it gives me a floating point exception.
I tried to replace the last line’s parameters by %ah and %si.
Briefly, I am trying to divide %esi by 15. I only want an int, and have no need for a double.
Thank you
The
divinstruction divides the two-word parameterdx/axby the operand. If the quotient is too large to fit into a word, it will throw that exception.Reference: http://siyobik.info.gf/main/reference/instruction/DIV
What do you have in the
dxregister? Most likelydx/axdivided by15does not fit in a 16-bit word.