CASE

VAX11

 

CASE   CASE INSTRUCTIONS

 

Purpose

perform multi-way branching depending on arithmetic input

Format

opcode selector.rx, base.rx, limit.rx, displ[0].bw,...,displ[limit].bw

Operation

tmp ß selector - base;

PC ß PC + if tmp LEQU limit then

SEXT (displ [tmp]) else {2 + 2* ZEST (limit)};

Condition codes

N ß temp LSS limit;

Z ß temp EQL limit;

V ß 0;

C ß temp LSSU limit;

Exceptions

none

Opcodes

8F        CASEB                       Case Byte

AF       CASEW                      Case Word

CF       CASEL                        Case Long

Description

The base operand is subtracted from the selector operand and a temporary is replaced            by the result. The temporary is compared with the limit operand and if it is less than or equal unsigned, a branch displacement selected by the temporary value is added to PC and PC is replaced by the result. Otherwise, 2 times the sum of the limit operand plus 1 is added to PC and PC is replaced by the result. This causes PC to be moved past the array of branch displacements. Regardless of the branch taken, the condition codes are affected by the comparison of the temporary operand with the limit operand.

Notes

1. After operand evaluation, PC is pointing at displ [0] not the next instruction. The branch displacements are relative to the address of displ [0].

2. The selector and base operands can both be considered either as signed or unsigned integers.

3. The limit is {the number of choices}-1.