Swap top two operand stack words
Format
swap_x
mn
Forms
swap_x = 64 (0x40)
Stack
…, wordM+N, …, wordM+1, wordM, …, word1 → …, wordM, …, word1, wordM+N, …, wordM+1
Description
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.
Notes
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.