Question

Is it possible to do comparison between two integer immediates, such as cmp $1, $2 or test $1, $2?

I keep getting error messages from gcc/as, saying "suffix or operands invalid for cmp". The exact line is

cmpq $2, $1001
Was it helpful?

Solution

x86 require no matter when one of the operands is a register, so this is impossible.

Suggestion: since it is two immediates and if your code isn't self-modifying, you can base on the result and hand-optimise the remaining code and replace operations that reads the flags with ones that does not appropriately.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top