Contents Prev Next Up

## The Virtual Machine Instruction Set

# Stack Instructions

nop
pop
pop2
dup
dup2
dup_x1
dup2_x1
dup_x2
dup2_x2
swap

### nop

Do nothing.

    no change

Do nothing.

### pop

Pop top stack word

    ..., any => ...

Pop the top word from the stack.

### pop2

Pop top two stack word
s

    ..., any2, any1 => ...

Pop the top two words from the stack.

### dup

Duplicate top stack word

    ..., any => ..., any, any

Duplicate the top word on the stack.

### dup2

Duplicate top two stack word
s

    ..., any2, any1 => ..., any2, any1, any2, any1

Duplicate the top two words on the stack.

### dup_x1

Duplicate top stack word and put two down

    ..., any2, any1 => ..., any1, any2, any1

Duplicate the top word on the stack and insert the copy two words down in the stack.

### dup2_x1

Duplicate top two stack words and put two down

    ..., any3, any2, any1 => ..., any2,, any1, any3, any2, any1

Duplicate the top two words on the stack and insert the copies two words down in the stack.

### dup_x2

Duplicate top stack word and put three down.

    ..., any3, any2, any1 => ..., any1, any3, any2, any1

Duplicate the top word on the stack and insert the copy three words down in the stack.

### dup2_x2

Duplicate top two stack words and put three down

    ..., any4, any3, any2, any1 => ..., any2, any1, any4, any3, any2, any1

Duplicate the top two words on the stack and insert the copies three words down in the stack.

### swap

Swap top two stack words

    ..., any2, any1 => ..., any2, any1

Swap the top two elements on the stack.

Contents Prev Next Up

Generated with CERN WebMaker