The difference between cmpl and cmp

前端 未结 3 1610
星月不相逢
星月不相逢 2021-02-07 17:50

I am trying to understand assembly to be able to solve a puzzle. However I encountered the following instructions:

0x0000000000401136 <+44>:    cmpl   $0x7,         


        
3条回答
  •  离开以前
    2021-02-07 18:44

    I don't think x86 actually has an instruction called CMPL. It's probably part of your assembler syntax to give hints on operands or something else (like JZ and JE being the same).

    From the intel manual on what it is doing:

    Compares the first source operand with the second source operand and sets the status flags in the EFLAGS register according to the results. The comparison is performed by subtracting the second operand from the first operand and then setting the status flags in the same manner as the SUB instruction. When an immediate value is used as an operand, it is sign-extended to the length of the first operand.

    Sign-ness is given implicitly, because of the two's complement representation of numbers.

    How to manipulate the jump? If you are sure that the jump should do the exact opposite than what it is doing, you just have to change JA to JBE.

提交回复
热议问题