flumpb
flumpb

Reputation: 1776

cmp and ja question

I'm having problems understanding this. It's in intel syntax

cmp eax, 0x19
ja greater

eax contains the value -40. http://en.wikibooks.org/wiki/X86_Assembly/Control_Flow tells me ja is the unsigned comparison from the previous cmp.

As far as I know, this should jump IF arg1 (0x19) is ABOVE arg2 (0xffffffd8)

0x19 looks smaller than 0xffffffd8 to me. The jump is being performed. Any help understanding my flawed logic much appreciated!

Upvotes: 3

Views: 17670

Answers (2)

geometrian
geometrian

Reputation: 15387

Maybe, 0xffffffd8 is a negative number in two's complement 32 bit. 0x19 is positive.

Upvotes: 0

Jerry Coffin
Jerry Coffin

Reputation: 490148

This is a little hard to answer because different assemblers reverse the order of operands. From the looks of things, you seem to be using Intel syntax assembly, in which case what you have is roughly equivalent to if (unsigned)eax > 0x19 goto greater. That being the case, it's reasonable that the jump is taken.

Upvotes: 8

Related Questions