Duplicate top two operand stack words and put four down
Bytecode
Type | Description |
u1 | dup2_x2 opcode = 0x5E (94) |
Stack ..., word4, word3, word2, word1 => ..., word2, word1, word4, word3, word2, word1
Description
Duplicates the top two-word item on the stack and inserts the
duplicate before the previous (two-word) item on the stack. Alternatively, this
instruction could be used to duplicate two single-word items and insert them before the
before the third two-word (or fourth single-word) item on the stack.
The top two words on the operand stack are duplicated and the copies inserted, in the original order, four words down in the operand stack.
The dup2_x2 instruction must not be used unless each of word1 and word2 is a 32-bit data type or both together are the two words of a single 64-bit datum, and unless word3 and word4 are each a word that contains a 32-bit data type or both together are the two words of a single 64-bit datum.
Except for restrictions preserving the integrity of 64-bit data types, the dup2_x2 instruction operates on untyped words, ignoring the types of the data they contain.
Example
bipush 100 bipush 200 dconst_0 ; stack now contains: ; 0.0 | double-word1 ; 0.0 | double-word2 ; 200 integer2-word1 ; 100 integer1-word1 dup2_x2 ; stack now contains: ; 0.0 | double-word1 ; 0.0 | double-word2 ; 200 integer2-word1 ; 100 integer1-word1 ; 0.0 | double-word1 ; 0.0 | double-word2