Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 938
flumpb Avatar asked Aug 26 '26 01:08

flumpb


1 Answers

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.

like image 122
Jerry Coffin Avatar answered Aug 28 '26 22:08

Jerry Coffin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!