Stash operations
Add, remove and change the order of values in the stack.
| OP |
in |
out |
note |
LIT |
|
a |
push the next value (no k mod) |
POP |
a |
|
remove first value |
NIP |
a b |
b |
remove second value |
SWP |
a b |
b a |
switch first and second values |
ROT |
a b c
|
b c a
|
switch third value to first |
DUP |
a |
a a |
copy first value |
OVR |
a b |
a b a
|
copy second value |
STH |
a |
|
push a to RS (r mod, use WS)
|
Math operations
Apply mathe operations on values in the stack.
| OP |
in |
out |
note |
INC |
a |
b |
b = a + 1 |
ADD |
a b |
c |
c = a + b
|
SUB |
a b |
c |
c = a - b
|
MUL |
a b |
c |
c = a * b
|
DIV |
a b |
c |
c = a / b
|
AND |
a b |
c |
c = a & b, bitwise
|
ORA |
a b |
c |
c = a | b, bitwise
|
EOR |
a b |
c |
c = a ^ b, bitwise
|
SFT |
a b' |
c |
split b into hi and lo, shift
a
right by lo, left by hi
|
EQU |
a b |
c' |
c = 01 if a = b else c =
00
|
NEQ |
a b |
c' |
c = 01 if a <> b else
c = 00
|
GTH |
a b |
c' |
c = 01 if a > b else
c = 00
|
LTH |
a b |
c' |
c = 01 if a < b else
c = 00
|
Jump operations
Change the current position of the program. Can be used for
routines, if-else, loops. JMI and derivates do not have 2rk modes.
Beware of infinite loops and jumps to unknown positions.
| OP |
in |
out |
note |
JMP |
p |
|
change PC by p' signed value (2 mod, jump to p'')
|
JCN |
a' p |
|
if a <> 00, do JMP
|
JSR |
p |
|
push PC to RS, do JMP (r mod, use WS)
|
JMI |
|
|
jump to next value rel addr |
JCI |
a |
|
if a <> 00, do JMI
|
JSI |
|
|
push (PC+2)'', do JMI |
Memory operations
Store values in memory. Can be used to store an object and use
p'' as a pointer to it. Be careful not to overwrite data.
| OP |
in |
out |
note |
LDZ |
p' |
a |
push a from Z page addr
|
LDR |
p' |
a |
push a from rel addr |
LDA |
p'' |
a |
push a from addr |
STZ |
a p' |
|
write a to Z page addr
|
STR |
a p' |
|
write a to rel addr |
STA |
a p'' |
|
write a to addr |
DEI |
p' |
a |
push a from device |
DEO |
a p' |
|
write a to device |
Modes
| MOD |
name |
note |
2 |
short |
ops use 2-byte shorts, unless marked with ' for byte or '' for
short
|
r |
return |
values are read/written from/to the return stack
|
k |
keep |
values read from the stack are not removed
|