Kenshi
Kenshi

Reputation: 11

Assembling with gcc gives error operand type mismatch for `cmp' for some integers, not others

This is a weird one. I'm using gcc to assemble a program and I want to know if the value in register rsi fits in 32 bits, so I use this instruction:

cmpq $0xffffffff, %rsi

I get back an error that there's an operand mismatch. I've been playing around with it and if I delete one or more of the letters f, so for instance $0xfffffff, the error goes away. If there are eight to fifteen letters f, it gives the operand mismatch error. However, at sixteen (the maximum 64-bit number), the error goes away again. Putting a leading 0 after the x doesn't seem to help.

I suspect this is a bug with gcc, but I don't know how something so obvious as this could go unnoticed. Am I making a mistake in how I'm typing out hexadecimal numbers?

Upvotes: 1

Views: 92

Answers (0)

Related Questions