Site Tools


Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing


7.5.108 swap_x

Swap top two operand stack words





swap_x = 64 (0x40)


…, wordM+N, …, wordM+1, wordM, …, word1 → …, wordM, …, word1, wordM+N, …, wordM+1


The unsigned byte mn is used to construct two parameter values. The high nibble, (mn& 0xf0) » 4, is used as the value m. The low nibble, (mn& 0xf), is used as the value n. Permissible values for both m and n are 1 and 2.

The top m words on the operand stack are swapped with the n words immediately below.

The swap_x instruction must not be used unless the ranges of words 1 through m and words m+1 through n each contain either a 16-bit data type, two 16-bit data types, a 32-bit data type, a 16-bit data type and a 32-bit data type (in either order), or two 32-bit data types.


Except for restrictions preserving the integrity of 32-bit data types, the swap_x instruction operates on untyped words, ignoring the types of data they contain.

If a virtual machine does not support the int data type, the only permissible value for both m and n is 1.

javacard/jcvm/7.5.108_swap_x.txt · Last modified: 2017/05/13 04:08 (external edit)