UMBC Technical Details Previous | Next

Some Technical Details on on Compares and Jumps

The 80X86 encodes all conditional bytes with an opcode and a displacement byte, since most jumps are to nearby locations. The CPU: There will be times when the short jump will not be far enough. When that happens, you can just use the JUMP instruction. The assembler will assume that you want a two-byte displacement. (To prevent that, you must put the word SHORT in front of the label.)

Sometimes you will get a "jump out of range" error message. Replace your instruction (such as):

      jcond  aLabel with       jNcond JAJ1
      jmp    aLabel
This converts a two-byte instruction into two instructions with a total of five bytes. Note that this is a jump around a jump and is not considered good style, but it is the only way for you get cure the "jump out of range" error message.

The Intel manual states:

"The target instruction is specified with a relative offset (a signed offset relative to the current value of the instruction pointer in the EIP register). A relative offset (rel8, rel16, rel32 is generally specified as a label in assembly code, but at the machine level, it is encoded as a signed, 8-bit or 32-bit immediate value, which is added to the instruction pointer. Instruction coding is most efficient for offsets of -128 to +127. If the operand-size attribute is 16, the upper two bytes of the EIP register are cleared to 0s, resulting in a maximum instruction pointer size of 16 bits.

Additionally, there loop instruction has a conditional version that allows you to combine two tests (checking the the zero flag) into one:

Previous | Next

©2004, Gary L. Burt