Hardware Reference
In-Depth Information
Conditional jumps
The 8088 has 15 conditional jumps, a few of which have two names (e.g.,
JUMP GREATER OR EQUAL is the same instruction as JUMP NOT LESS THAN ). They
are listed in Fig. C-5. All of these allow only jumps with a distance of up to 128
bytes from the instruction. If the destination is not within this range, a jump over
jump construction has to be used. In such a construction, the jump with the oppo-
site condition is used to jump over the next instruction. If the next instruction con-
tains an unconditional jump to the intended destination, then the effect of these two
instructions is just a longer-ranging jump of the intended type. for example
JB FARLABEL
becomes
JNA 1f
JMP FARLABEL
1:
In other words, if it is not possible to do JUMP BELOW , then a JUMP NOT ABOVE to
a nearby label 1 is placed, followed by an unconditional jump to FARLABEL . The
effect is the same, at a slightly higher cost in time and space. The assembler gener-
ates these jump over jumps automatically when the destination is expected to be
too distant. Doing the calculation correctly is a bit tricky. Suppose that the dis-
tance is close to the edge, but some of the intervening instructions are also condi-
tional jumps. The outer one cannot be resolved until the sizes of the inner ones are
known, and so on. To be safe, the assembler errs on the side of caution. Some-
times it generates a jump over jump when it is not strictly necessary. It only gener-
ates a direct condition jump when it is certain that the target is within range.
Most conditional jumps depend on the status flags, and are preceded by a com-
pare or test instruction. The CMP instruction subtracts the source from the desti-
nation operand, sets the condition codes and discards the result. Neither of the
operands is changed. If the result is zero or has the sign bit on (i.e., is negative),
the corresponding flag bit is set. If the result cannot be expressed in the allowed
number of bits, the overflow flag is set. If there is a carry out of the high-order bit,
the carry flag is set. The conditional jumps can test all of these bits.
If the operands are considered to be signed, the instructions using GREATER
THAN and LESS THAN should be used. If they are unsigned, the ones using ABOVE
and BELOW should be used.
C.4.5 Subroutine Calls
The 8088 has an instruction used to call procedures, usually known in assem-
bly language as subroutines . In the same way as in the jump instructions, there
exist near call instructions and far call instructions.
In the interpreter, only the
 
 
Search WWH ::




Custom Search