Site Tools


Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:7.5.66_itableswitch

7.5.66 itableswitch

Access jump table by int index and jump

Format

itableswitch

defaultbyte1

defaultbyte2

lowbyte1

lowbyte2

lowbyte3

lowbyte4

highbyte1

highbyte2

highbyte3

highbyte4

jump offsets…

Offset Format

offsetbyte1

offsetbyte2

Forms

itableswitch = 116 (0x74)

Stack

…, index → …

Description

An itableswitch instruction is a variable-length instruction. Immediately after the itableswitch opcode follow a signed 16-bit value default, a signed 32-bit value low, a signed 32-bit value high, and then high - low + 1 further signed 16-bit offsets. The value low must be less than or equal to high. The high - low + 1 signed 16-bit offsets are treated as a 0-based jump table. Each of the signed 16-bit values is constructed from two unsigned bytes as (byte1 « 8) | byte2. Each of the signed 32-bit values is constructed from four unsigned bytes as (byte1 « 24) | (byte2 « 16) | (byte3 « 8) | byte4.

The index must be of type int and is popped from the stack. If index is less than low or index is greater than high, then a target address is calculated by adding default to the address of the opcode of this itableswitch instruction. Otherwise, the offset at position index - low of the jump table is extracted. The target address is calculated by adding that offset to the address of the opcode of this itableswitch instruction. Execution then continues at the target address.

The target addresses that can be calculated from each jump table offset, as well as the one calculated from default, must be the address of an opcode of an instruction within the method that contains this itableswitch instruction.

Notes

If a virtual machine does not support the int data type, the itableswitch instruction will not be available.

javacard/jcvm/7.5.66_itableswitch.txt · Last modified: 2017/05/13 04:09 (external edit)