Format | Assembly Format | Description |
---|---|---|
45 <unsigned int32> <int32> … <int32> | switch ( t1, t2 … tN ) |
Jump to one of n values. |
…, value → …,
The switch
instruction implements a jump table. The format of the instruction is an unsigned int32
representing the number of targets N, followed by N int32
values specifying jump targets: these targets are represented as offsets (positive or negative) from the beginning of the instruction following this switch
instruction.
The switch
instruction pops value off the stack and compares it, as an unsigned integer, to n. If value is less than n, execution is transferred to the value'th target, where targets are numbered from 0 (i.e., a value of 0 takes the first target, a value of 1 takes the second target, and so on). If value is not less than n, execution continues at the next instruction (fall through).
If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction. (Such transfers are severely restricted and shall use the leave
instruction instead; see Partition I for details).
None.
Correct CIL obeys the control transfer constraints listed above.
Verification requires the type-consistency of the stack, locals and arguments for every possible way of reaching all destination instructions. See §III.1.8 for more details.