13.07.2015 Views

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

24594 Rev. 3.10 February 2005 AMD64 TechnologyJccJump on ConditionChecks the status flags in the rFLAGS register <strong>and</strong>, if the flags meet the conditionspecified by the condition code in the mnemonic (cc), jumps to the target instructionlocated at the specified relative offset. Otherwise, execution continues with theinstruction following the Jcc instruction.Unlike the unconditional jump (JMP), conditional jump instructions have only twoforms—short <strong>and</strong> near conditional jumps. Different opcodes correspond to differentforms of one instruction. For example, the JO instruction (jump if overflow) hasopcode 0Fh 80h for its near form <strong>and</strong> 70h for its short form, but the mnemonic is thesame for both forms. The only difference is that the near form has a 16- or 32-bitrelative displacement, while the short form always has an 8-bit relative displacement.Mnemonics are provided to deal with the programming semantics of both signed <strong>and</strong>unsigned numbers. <strong>Instructions</strong> tagged A (above) <strong>and</strong> B (below) are intended for usein unsigned integer code; those tagged G (greater) <strong>and</strong> L (less) are intended for use insigned integer code.If the jump is taken, the signed displacement is added to the rIP (of the followinginstruction) <strong>and</strong> the result is truncated to 16, 32, or 64 bits, depending on oper<strong>and</strong>size.In 64-bit mode, the oper<strong>and</strong> size defaults to 64 bits. The processor sign-extends the8-bit or 32-bit displacement value to 64 bits before adding it to the RIP.These instructions cannot perform far jumps (to other code segments). To create a farconditional-jumpcode sequence corresponding to a high-level language statementlike:IF A = B THEN GOTO FarLabelwhere FarLabel is located in another code segment, use the opposite condition in aconditional short jump before an unconditional far jump. Such a code sequence mightlook like:cmp A,B ; compare oper<strong>and</strong>sjne NextInstr ; continue program if not equaljmp far FarLabel ; far jump if oper<strong>and</strong>s are equalNextInstr:; continue programFor details about control-flow instructions, see “Control Transfers” in <strong>Volume</strong> 1, <strong>and</strong>“Control-Transfer Privilege Checks” in <strong>Volume</strong> 2.Jcc 165

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!