SWITCH - generate a jump table.

Usage:

switch   OFFSET,REG,LABLIST

Examples:

switch  -1,al,[lab2,lab3]   # go to lab2 if al==2
switch  0,x0    # Nargs in x0
ldq defalt      # Fill in default second arg

Where:

OFFSET
is a fixed word offset value to add to the switch index in REG when indexing into the jump table.
REG
is the register used to index into the jump table (in a TRA instruction).
LABLIST
is an optional token sequence expression giving a list of location names.

Description:

"switch" builds a jump table. It is normally used to do processing for default arguments. If LABLIST is supplied, it is used to generate a table of addresses that are indirected through with an indexed transfer. For example,

switch  0,al,[lab1,lab2,lab3]

results in code that will jump to "lab1" if "al" contains 1, "lab2" if "al" contains 2, and "lab3" if "al" contains 3. Note that the index of the first label in the table is 1.

If you omit LABLIST, the jump is into a sequence of single instructions immediately following the "switch" macro. The instruction immediately following the "switch" has an index of 1.

Copyright © 1996, Thinkage Ltd.