Next: , Previous: Comparison operators, Up: MIX instruction set


2.1.2.7 Jump operators

The MIX computer has an internal register, called the location counter, which stores the address of the next instruction to be fetched and executed by the virtual CPU. You cannot directly modify the contents of this internal register with a load instruction: after fetching the current instruction from memory, it is automatically increased in one unit by the MIX. However, there is a set of instructions (which we call jump instructions) which can alter the contents of the location counter provided some condition is met. When this occurs, the value of the next instruction address that would have been fetched in the absence of the jump is stored in `rJ' (except for JSJ), and the location counter is set to the value of `M' (so that the next instruction is fetched from this new address). Later on, you can return to the point when the jump occurred reading the address stored in `rJ'.

The MIX computer provides the following jump instructions: With these instructions you force a jump to the specified address. Use `JSJ' if you do not care about the return address.

JMP
Unconditional jump. OPCODE = 39, MOD = 0.
JSJ
Unconditional jump, but rJ is not modified. OPCODE = 39, MOD = 1.

These instructions check the overflow toggle to decide whether to jump or not.

JOV
Jump if OV is set (and turn it off). OPCODE = 39, MOD = 2.
JNOV
Jump if OV is not set (and turn it off). OPCODE = 39, MOD = 3.

In the following instructions, the jump is conditioned to the contents of the comparison flag:

JL
Jump if [CM] = L. OPCODE = 39, MOD = 4.
JE
Jump if [CM] = E. OPCODE = 39, MOD = 5.
JG
Jump if [CM] = G. OPCODE = 39, MOD = 6.
JGE
Jump if [CM] does not equal L. OPCODE = 39, MOD = 7.
JNE
Jump if [CM] does not equal E. OPCODE = 39, MOD = 8.
JLE
Jump if [CM] does not equal G. OPCODE = 39, MOD = 9.

You can also jump conditioned to the value stored in the MIX registers, using the following instructions:

JAN
JAZ
JAP
JANN
JANZ
JANP
Jump if the content of rA is, respectively, negative, zero, positive, non-negative, non-zero or non-positive. OPCODE = 40, MOD = 0, 1, 2, 3, 4, 5.
JXN
JXZ
JXP
JXNN
JXNZ
JXNP
Jump if the content of rX is, respectively, negative, zero, positive, non-negative, non-zero or non-positive. OPCODE = 47, MOD = 0, 1, 2, 3, 4, 5.
JiN
JiZ
JiP
JiNN
JiNZ
JiNP
Jump if the content of rIi is, respectively, negative, zero, positive, non-negative, non-zero or non-positive. OPCODE = 40 + i, MOD = 0, 1, 2, 3, 4, 5.