swap

Swap top two operand stack words

Bytecode

Type Description
u1 swap opcode = 0x5F (95)

Stack ..., word2, word1 => ..., word1, word2

Description

The top two words on the operand stack are swapped.

The swap instruction must not be used unless each of word2 and word1 is a word that contains a 32-bit data type.

Notes

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

There is no swap2, although you could use:

    dup2_x2
    pop2

to achieve the same effect.