# Name:
pop
Syntax:

POP variable { , variable, variable ... }

Description:

Receives a word variable value from the stack.

The last value on the word stack is copied into the variable.

Pushing and popping order

Note that variables need to be popped in the reverse order to which they are pushed on to the stack. If b1 is pushed before b2, then b2 needs to be popped before b1.

When b1 and b2 are pushed in a single command, the order of those variables need to be reversed in the corresponding pop command -

push b1, b2
gosub myroutine
pop b2, b1

This is the same as -

push b1
push b2
gosub myroutine
pop b2
pop b1

Applies To:
20X2, 28X2, 40X2
Related Create:
Share:
Print: ## Simple push and pop

This example shows how a variable (b0 here) can be pushed to the stack, have its value changed, then have its original value restored after a pop.

Code Example:
```main:	b0 = 0
sertxd( "Before push, b0=", #b0, cr, lf )
push b0
sertxd( "After push, b0=", #b0, cr, lf )
b0 = 99
sertxd( "After change, b0=", #b0, cr, lf )
pop b0
sertxd( "After pop, b0=", #b0, cr, lf )
end```
Copy Code Submit an Example

## Pushing and popping multiple variables

Note that variables must be popped in the reverse order to which they are pushed on to the stack. Here b1 is pushed before b2, therefore b2 needs to be popped before b1.

Code Example:
```main:	b1 = 11
b2 = 22
push b1
push b2
b1 = 99
b2 = 99
pop b2
pop b1
sertxd( "b1=", #b1, " b2=", #b2, cr, lf )
end```
Copy Code Submit an Example

## Pushing and popping multiple variables in same command

Note that variables must be popped in the reverse order to which they are pushed on to the stack. Here b1 is pushed before b2, therefore b2 needs to be popped before b1. When b1 and b2 are pushed in a single command, the order of those variables need to be reversed in the corresponding pop command.

Code Example:
```main:	b1 = 11
b2 = 22
push b1, b2
b1 = 99
b2 = 99
pop b2, b1
sertxd( "b1=", #b1, " b2=", #b2, cr, lf )
end```
Copy Code Submit an Example