# HoldingDownTheForth

1000 DIM STACK\$(10)
1100 PTR = 0
2000 OPEN "RAM:PROG.DO" FOR INPUT AS 1
2200 INPUT #1, W\$
2320 IF W\$ = "end" THEN 5000
2400 IF W\$ = "emit" THEN GOSUB 30400
2500 IF W\$ = "." THEN GOSUB 30500
2600 IF W\$ = "dup" THEN GOSUB 30700
2700 IF W\$ = "cr" THEN GOSUB 30800
2800 IF W\$ = "drop" THEN GOSUB 30900
2900 IF W\$ = "+" THEN GOSUB 31200
3000 IF W\$ = "-" THEN GOSUB 32200%
3100 IF W\$ = "*" THEN GOSUB 33200
3200 IF W\$ = "/" THEN GOSUB 34200
3300 REM Everything else gets pushed...
3301 IF W\$ <> "" THEN GOSUB 21000
3305 GOTO 2200
5000 CLOSE 1: END
21000 REM push
21010 PTR = PTR + 1
21020 STACK\$(PTR) = W\$
21030 RETURN
22000 REM pop
22010 W\$ = STACK\$(PTR)
22020 PTR = PTR - 1
22030 RETURN
30400 REM emit
30410 W\$ = STACK\$(PTR)
30420 V = VAL(W\$)
30430 PRINT CHR\$(V)
30440 RETURN
30500 REM .
30510 GOSUB 22000
30520 PRINT W\$
30530 RETURN
30700 REM dup
30710 W\$ = STACK\$(PTR)
30720 PTR = PTR + 1
30730 STACK\$(PTR) = W\$
30760 RETURN
30800 REM CR
30810 PRINT CHR\$(13)
30820 RETURN
30900 REM drop
30910 GOSUB 22000
30920 RETURN
31200 REM +
31210 GOSUB 22000
31220 RH = VAL(W\$)
31230 GOSUB 22000
31240 LH = VAL(W\$)
31250 RT = LH + RH
31260 W\$ = STR\$(RT)
31270 GOSUB 21000
31280 RETURN
32200 REM -
32210 GOSUB 22000
32220 RH = VAL(W\$)
32230 GOSUB 22000
32240 LH = VAL(W\$)
32250 RT = LH - RH
32260 W\$ = STR\$(RT)
32270 GOSUB 21000
32280 RETURN
33200 REM *
33210 GOSUB 22000
33220 RH = VAL(W\$)
33230 GOSUB 22000
33240 LH = VAL(W\$)
33250 RT = LH * RH
33260 W\$ = STR\$(RT)
33270 GOSUB 21000
33280 RETURN
34200 REM /
34210 GOSUB 22000
34220 RH = VAL(W\$)
34230 GOSUB 22000
34240 LH = VAL(W\$)
34250 RT = LH / RH
34260 W\$ = STR\$(RT)
34270 GOSUB 21000
34280 RETURN