switch OFFSET,REG,LABLIST
switch -1,al,[lab2,lab3] # go to lab2 if al==2 switch 0,x0 # Nargs in x0 ldq defalt # Fill in default second arg
"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.