cmp and ja question

16,422

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.

Share:
16,422
flumpb
Author by

flumpb

Updated on June 04, 2022

Comments

  • flumpb
    flumpb almost 2 years

    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!