I am currently writing a compiler which produces x86-32 code.
However, I have a problem when trying to implement division.
idivl %ecx, %ebx
This code gives me the following error:
Error: operand type mismatch for `idiv'
Does anyone know why? The above lines are the only time idiv appears in my code.
According to my reference,
IDIVdivides the 64-bit integerEDX:EAXby the provided register’s value.The
idivlinstruction behaves exactly likeidiv, exceptidivlis a signed division.See http://www.cs.virginia.edu/~evans/cs216/guides/x86.html
Another great ref: http://ref.x86asm.net/