### PUSH/POP stack

Posted:

**Thu Dec 21, 2017 12:41 pm**As requested in another topic.

Before first use, create a 1x4 matrix and call it "STACK".

Of course, the stack may not hold complex numbers or matrices.

POPST will put back the original LXYZT as XNYZT, with N the X-register content before calling POPST; consistent with the way a 1-argument function works. To restore the stack mimicking a 2-argument function (thus returning XNZTT) use

Cheers, Werner

Before first use, create a 1x4 matrix and call it "STACK".

Of course, the stack may not hold complex numbers or matrices.

Code: Select all

```
00 { 74-Byte Prgm }
01>LBL "PUSHST"
02 INDEX "STACK"
03 INSR
04 R^
05 STOEL
06 J+
07 R^
08 STOEL
09 J+
10 R^
11 STOEL
12 J+
13 R^
14 STOEL
15 EXITALL
16 RTN
17>LBL "POPST"
18 INDEX "STACK"
19 STO ST L
20 RCLEL
21 ENTER
22 ->
23 ENTER
24 ->
25 ENTER
26 ->
27 DELR
28 EXITALL
29 X<> ST L
30 END
```

Code: Select all

```
>LBL "POP2ST"
INDEX "STACK"
STO ST L
RCLEL
ENTER
ENTER
->
J+
ENTER
->
DELR
EXITALL
X<> ST L
RTN
```