CASE Instruction

Purpose:To perform multi-way branching depending on arithmetic input.
Format:opcode select.rx, base.rx, limit.rx
.word displ[0].bw
...
.word displ[limit].bw
Operation:
tmp <- selector - base;
if temp <= limit then
PC <- PC + sign-extended displ[temp];
else
PC <- PC + (2 + 2 * limit);
Condition
Codes:
N <- temp LSS limit;
Z <- temp EQL limit;
V <- 0;
C <- tmp LSSU limit;
Exceptions:None
Opcodes:
8FCASEBCase Byte
AFCASEWCase Word
CFCASELCase Long
Description: The base operand is subtracted from the selector operand and a temporary is replace with the result. The temporary is compared with the limit operand and if it is less than (unsigned) or equal to , a branch displacement selected by the temporary value is added to the PC and the PC is replaced by the result. Otherwise two times the sum of the limit operand and one is added to the PC and the PC is replaced with the result. This causes the PC to be moved past the array of branch displacements. Regardless of the branch being taken, the condition codes are affected by the comparison of the temporary with the limit operand.
Notes:
1.
After operand evaluation, the PC is pointing at displ[0], not the next instruction. The branch displacments are relative to the address of displ[0].
2.
The selector and base operands can both be considered either as signed or unsigned integers.