How is the x86 JAE instruction related to the carry flag?

15,370

Solution 1

jae is the same as jnc, i.e. jump if CF == 0. Choice between all 3 mnemonics (including jnb) is up to programmer. CF isn't set here by mov but by a previous instruction. The mnemonics jae is recommended after compare instruction (cmp) which does subtraction. You can get more details in Intel or AMD software developer manuals.

Solution 2

jae means Jump if above or equal. It will jump if the carry flag is equal to 0.

You're looking for jnae or jb

Share:
15,370
user997112
Author by

user997112

Updated on June 20, 2022

Comments

  • user997112
    user997112 almost 2 years

    I have some x86 code which looks like:

    ;  The carry flag is set to 1 here
    jae    an_address  ; The jump instruction does not take place
    

    Does this make sense?

    I thought the jump should take place because 1 is greater than or equal to 0, the definition of JAE?

  • user997112
    user997112 over 9 years
    I'm not looking for anything :) I am looking at code which contains jae, CF is zero and the jump is not being taken?
  • Nowayz
    Nowayz over 9 years
    You must be looking at something wrong, becasue that's not how jae behaves
  • user997112
    user997112 over 9 years
    Im debugging in Visual Studio, I can see the value of the carry flag and when I step-in, the debugger doesn't jump to the address of the branch, just continues right over it.
  • Nowayz
    Nowayz over 9 years
    in your question you say the carry flag is 1, is this not the case?
  • user997112
    user997112 over 9 years
    Sorry- I meant carry is initially zero, then it is set to 1, then the JAE occurs and there's no branch.
  • Rudy Velthuis
    Rudy Velthuis over 9 years
    Because JAE jumps when the carry flag is 0, so if it is not 0, the jump should not take place, as you observe.