6
Jump Instructions |
The jump instructions are of four types: unconditional, conditional, indexed, or absolute. The conditional jumps test against zero or compare two signed or unsigned operands. The indexed jumps index tables of displacements found in the current code segment. They are used to implement case statements. All jumps are program-counter-relative, and all displacements are measured in bytes, relative to the first byte of the instruction (recorded in savedPC). The following example shows the two possible successors of a Jump Less Byte instruction (defined in §6.3):
Note: Most of the jump opcodes add signed displacements, obtained by sign-extending alpha, to the unsigned PC. The only unsigned jump displacements are in the Jump Indexed instructions. All but JIW have their displacement in [-32768..32767]. Arithmetic on the PC is always performed modulo 216, and overflow is ignored.
These instructions add a small constant, a sign-extended byte, or an INTEGER to the PC.
Jn: PROCEDURE [n: [2..8]] = BEGIN PC savedPC + n; END;
JB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; PC savedPC + SignExtend[disp]; END;
JW: PROCEDURE = BEGlN disp: INTEGER = GetCodeWord[]; PC savedPC + disp; END;
The Jump Stack instruction sets the PC to the value popped from the stack:
JS: PROCEDURE = BEGIN PC Pop[]; END;
The Catch instruction is used by the software to mark the code and indicate (in alpha) the catch phrase index. Except for its effects on the PC, Catch is a no-op.
CATCH: PROCEDURE = BEGIN alpha: BYTE = GetCodeByte[]; END;
The equality jumps compare the top two elements of the stack or the top element and a constant (alpha or zero) for equality and jump accordingly. The jump pair opcodes compare the top of the stack with a four-bit field of alpha, and add a second four-bit field of alpha to the PC if the comparison succeeds.
JZn: PROCEDURE [n: [3 4]] = BEGIN u: UNSPECIFIED = Pop[]; IF u = 0 THEN PC savedPC + n; END;
JNZn: PROCEDURE [n: [3..4]] = BEGIN u: UNSPECIFIED = Pop[]; IF u # 0 THEN PC savedPC + n; END;
JZB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; data: UNSPECIFIED = Pop[]; IF data = 0 THEN PC savedPC + SignExtend[disp]; END;
JNZB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; data: UNSPECIFIED = Pop[]; IF data # 0 THEN PC savedPC + SignExtend[disp]; END;
JEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: UNSPECIFIED = Pop[]; u: UNSPECIFIED = Pop[]; IF u = v THEN PC savedPC + SignExtend[disp]; END;
JNEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: UNSPECIFIED = Pop[]; u: UNSPECIFIED = Pop[]; IF u # v THEN PC savedPC + SignExtend[disp]; END;
JDEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: LONG UNSPECIFIED = PopLong[]; u: LONG UNSPECIFIED = PopLong[]; IF u = v THEN PC savedPC + SignExtend[disp]; END;
JDNEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: LONG UNSPECIFIED = PopLong[]; u: LONG UNSPECIFIED = PopLong[]; IF u # v THEN PC savedPC + SignExtend[disp]; END;
JEP: PROCEDURE = BEGIN pair: NibblePair = GetCodeByte[]; data: UNSPECIFIED = Pop[]; IF data = pair.left THEN PC savedPC + pair.right + 4; END;
JNEP: PROCEDURE = BEGIN pair: NibblePair = GetCodeByte[]; data: UNSPECIFIED = Pop[]; IF data # pair.left THEN PC savedPC + pair.right + 4; END;
JEBB: PROCEDURE = BEGIN byte: UNSPECIFIED = GetCodeByte[]; disp: BYTE = GetCodeByte[]; data: UNSPECIFIED = Pop[]; IF data = byte THEN PC savedPC + SignExtend[disp]; END;
JNEBB: PROCEDURE = BEGIN byte: UNSPECIFIED = GetCodeByte[]; disp: BYTE = GetCodeByte[]; data: UNSPECIFIED = Pop[]; IF data # byte THEN PC savedPC + SignExtend[disp]; END;
The signed jump instructions compare the top two elements of the stack as two's complement signed operands and add a sign-extended alpha to the PC if the comparison succeeds.
JLB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; k: INTEGER = Pop[]; j: INTEGER = Pop[]; IF j < k THEN PC savedPC + SignExtend[disp]; END;
JLEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; k: INTEGER = Pop[]; j: INTEGER = Pop[]; IF j <= k THEN PC savedPC + SignExtend[disp]; END;
JGB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; k: INTEGER = Pop[]; j: INTEGER = Pop[]; IF j > k THEN PC savedPC + SignExtend[disp]; END;
JGEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; k: INTEGER = Pop[]; j: INTEGER = Pop[]; IF j >= k THEN PC savedPC + SignExtend[disp]; END;
The unsigned jump instructions compare the top two elements of the stack as unsigned operands and add a sign-extended alpha to the PC if the comparison succeeds.
JULB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: CARDINAL = Pop[]; u: CARDINAL = Pop[]; IF u < v THEN PC savedPC + SignExtend[disp]; END;
JULEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: CARDINAL = Pop[]; u: CARDINAL = Pop[]; IF u <= v THEN PC savedPC + SignExtend[disp]; END;
JUGB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: CARDINAL = Pop[]; u: CARDINAL = Pop[]; IF u > v THEN PC savedPC + SignExtend[disp]; END;
JUGEB: PROCEDURE = BEGIN disp: BYTE = GetCodeByte[]; v: CARDINAL = Pop[]; u: CARDINAL = Pop[]; IF u >= v THEN PC savedPC + SignExtend[disp]; END;
The indexed jumps update the PC from a table of byte displacements located in the code segment at offset base from the code base CB. If index is less than limit, the index added to base is used to extract a displacement from a table located in the current code segment. This displacement is then added to the PC. If index is out of range, no jump occurs.
Jump Indexed Byte uses a table of eight-bit entries, Jump Indexed Word uses sixteen-bit entries. The entries in both tables contain displacements measured in bytes. Note that in JIB, the displacement is not sign-extended.
JIB: PROCEDURE = BEGIN disp: BytePair; base: CARDINAL = GetCodeWord[]; limit: CARDINAL = Pop[]; index: CARDINAL = Pop[]; IF index < limit THEN BEGIN disp ReadCode[base + index/2]; PC savedPC + (IF (index MOD 2) = 0 THEN disp.left ELSE disp.right); END; END;
JIW: PROCEDURE = BEGIN disp: CARDINAL; base: CARDINAL = GetCodeWord[]; limit: CARDINAL = Pop[]; index: CARDINAL = Pop[]; IF index < limit THEN BEGIN disp ReadCode[base + index]; PC savedPC + disp; END; END;
The ReadCode routine is defined in §3.1.4.3. Previous [TOC] Next
[last edited 5/4/99 9:32PM]