I get the following error:
Assembler messages:
Error: operand type mismatch for `cmp'
The only cmp in my code is:
"cmpl %eax, $15\n\t"
I don't get what is wrong with that - I have a register and an immediate value which should be implicitly sign extended to 32bit.
According to Official Intel ISA Reference 3.2 Instructions (A-L)
CMP EAX, imm32
Which means either in Intel Syntax
cmp eax, 15D
or in AT&T Syntax:
cmpl $15, %eax
Just the opposite :)
cmp doesn't have a form that subtracts the reg/mem from an immediate. Instead, use the opposite branch / cmov condition if you wanted to check something other than equality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With