CORE words: Arithmetic, Logic, Stack and Memory 


Arithmetic

Name Stack Effect Summary Token
ABS  ( x -- |x| ) absolute value of TOS xt = 0x96
UNDER1+  ( x1 x2 -- x1' x2 ) add 1 to NOS xt = 0x19A
1+  ( x -- x+1 ) add 1 to TOS xt = 0x50
( x1 x2 -- x3 ) add TOS to NOS xt = 0x28
UNDER+  ( a b c -- a+c b ) add TOS to item under NOS xt = 0x73
CELL+  ( x -- x+4 ) add cellsize to TOS xt = 0x6C
UM+  ( x1 x2 -- ud ) add top two items, double resul xt = 0x27
D2/  ( d1 -- d2 ) arithmetic right shift double xt = 0x6A
2/  ( x1 -- x2 ) arithmetic right shift one bit xt = 0x2F
>>A  ( x1 u -- x1>>u ) arithmetic right shift u places xt = 0x61
NEGATE  ( x -- -x ) negate TOS xt = 0x54
UMAX  ( n1 n2 -- n3 ) choose maximum of n1, n2 xt = 0x98
MAX  ( n1 n2 -- n3 ) choose maximum of n1, n2 xt = 0x9A
UMIN  ( n1 n2 -- n3 ) choose minimum of n1, n2 xt = 0x99
MIN  ( n1 n2 -- n3 ) choose minimum of n1, n2 xt = 0x9B
( n1 n2 -- q ) dividend divisor -- quot xt = 0xAC
MOD  ( n1 n2 -- r ) dividend divisor -- rem xt = 0xAA
/MOD  ( n1 n2 -- r q ) dividend divisor -- rem quot xt = 0xA9
DABS  ( d -- |d| ) double-cell absolute value xt = 0x97
D+  ( d1 d2 -- d3 ) double-cell add xt = 0x66
DNEGATE  ( xd1 -- -xd1 ) double-cell negate xt = 0x67
D-  ( d1 d2 -- d3 ) double-cell subtract xt = 0x68
FM/MOD  ( d1 n1 -- n2 n3 ) floored m/mod xt = 0xAF
WORD-JOIN  ( nl nh -- n ) join lo-16 hi-16 --> 32 xt = 0x1A0
BYTE-JOIN  ( cl ch -- n ) join lo and hi bytes xt = 0x19F
D2*  ( d1 -- d2 ) left shift double xt = 0x6B
0MAX  ( x -- u ) limit TOS to 0 xt = 0x9C
UD2/  ( d1 -- d2 ) logical right shift double xt = 0x69
U2/  ( x1 -- x2 ) logical right shift one bit xt = 0x2E
2*  ( x -- x*2 ) multiply TOS by 2 xt = 0x52
CELLS  ( x1 -- x2 ) multiply by cell size xt = 0x6D
*/  ( n1 n2 n3 -- q ) n1*n2/n3 --> quot xt = 0xAE
*/MOD  ( n1 n2 n3 -- r q ) n1*n2/n3 --> rem quot xt = 0xAB
BOUNDS  ( a n -- aend abeg ) set up for DO..LOOP xt = 0x9F
W>N  ( c -- n ) sign extend 16-bit --> cell xt = 0x183
C>N  ( c -- x ) sign extend byte --> cell xt = 0x182
M/MOD  ( d n -- r q ) signed d/n --> r q xt = 0xA5
M*  ( n1 n2 -- d ) signed mult, double-cell result xt = 0xA7
( n1 n2 -- n3 ) signed mult, single-cell result xt = 0xAD
S>D  ( n -- d ) signed single --> signed double xt = 0x95
WORD-SPLIT  ( n -- nl nh ) split 32 --> lo-16 hi-16 xt = 0x19E
BYTE-SPLIT  ( w -- cl ch ) split into lo and hi bytes xt = 0x19D
UNDER1-  ( x1 x2 -- x1' x2 ) subtract 1 from NOS xt = 0x19B
1-  ( x -- x-1 ) subtract 1 from TOS xt = 0x51
( x1 x2 -- x3 ) subtract TOS from NOS xt = 0x29
CELL-  ( x -- x-4 ) subtract cellsize from TOS xt = 0x199
BYTE-SWAP  ( n -- n' ) swap lower 2 bytes of n xt = 0x1A1
SM/REM  ( d1 n2 -- n2 n3 ) symmetric m/mod xt = 0xB0
UD*  ( ud1 u -- ud2 ) unsigned 32*16 -> 32 multiply xt = 0x1C8
UM*  ( u1 u2 -- ud ) unsigned 32*32 --> 64 multiply xt = 0xA3
UM/MOD  ( ud u -- r q ) unsigned 64/32 --> r32 q32 xt = 0xA4
U/MOD  ( u1 u2 -- r q ) unsigned u/u --> r q xt = 0xA8
MU/MOD  ( ud# un1 -- rem d#quot ) unsigned ud/u --> ur udq xt = 0xA6

Logic

Name Stack Effect Summary Token
0<  ( x -- f ) T if negative xt = 0x2B
0>=  ( x -- f ) T if non-negative xt = 0x59
0>  ( x -- f ) T if non-negative xt = 0x5B
0<>  ( x -- f ) T if nonzero xt = 0x58
0<=  ( x -- f ) T if not positive xt = 0x5A
0=  ( x -- f ) T if zero xt = 0x2A
INVERT  ( x -- ~x ) bitwise invert TOS xt = 0x53
AND  ( x1 x2 -- x3 ) and top two stack items xt = 0x24
BIT-OFF  ( bit# addr -- ) clear bit# of char at addr xt = 0x93
ON?  ( addr -- f ) flag at addr <> 0? xt = 0x90
OFF?  ( addr -- f ) flag at addr = 0? xt = 0x91
LSHIFT  ( x1 u -- x1<<u ) left shift u places xt = 0x5F
WITHIN  ( u ul uh -- f ) lo <= n < hi unsigned xt = 0x9D
BETWEEN  ( n lo hi --- f1 ) lo <= n <= hi signed xt = 0x9E
RSHIFT  ( x1 u -- x1>>u ) logical right shift u places xt = 0x60
XOR  ( x1 x2 -- x3 ) or top two stack items xt = 0x26
OR  ( x1 x2 -- x3 ) or top two stack items xt = 0x25
BIT-ON  ( bit# addr -- ) set bit# of char at addr xt = 0x92
BIT?  ( bit# addr -- f ) test bit# of char at addr xt = 0x94
( x1 x2 -- f ) true if NOS < TOS signed xt = 0x86
U<  ( u1 u2 -- flag ) true if NOS < TOS unsigned xt = 0x8A
( x1 x2 -- f ) true if NOS = TOS xt = 0x5C
<>  ( x1 x2 -- f ) true if NOS = TOS xt = 0x5D
( x1 x2 -- f ) true if NOS > TOS xt = 0x88
<=  ( x1 x2 -- f ) true if NOS > TOS xt = 0x89
>=  ( x1 x2 -- f ) true if NOS >= TOS xt = 0x87
D0<  ( d -- f ) true if double-cell < 0 xt = 0x8C
D0<>  ( d -- f ) true if double-cell <> 0 xt = 0x8D
D0=  ( d -- f ) true if double-cell = 0 xt = 0x8B

Stack 

Name Stack Effect Summary Token
DEPTH  ( -- addr ) # of cells on the data stack xt = 0x18D
-1  ( -- x ) -1  xt = 0x4A
( -- x ) xt = 0x4B
( -- x ) xt = 0x4C
( -- x ) xt = 0x4D
PLUCK  ( x1 x2 x3 -- x1 x2 x3 x1 ) same as 2 pick xt = 0x75
BL  ( -- x ) ASCII blank xt = 0x4E
CELL  ( -- x ) address units per cell xt = 0x47
FALSE  ( -- x ) all '0' bits xt = 0x49
TRUE  ( -- x ) all '1' bits xt = 0x48
2OVER  ( a b c d -- a b c d a b ) copy 2nd cell pair xt = 0x64
OVER  ( x1 x2 -- x1 x2 x1 ) copy 2nd item on the stack xt = 0x23
R@  ( -- x ) copy cell from return stack xt = 0x55
DUP>R  ( x -- x ) copy cell to return stack xt = 0x56
2R@  ( -- d ) copy double from return stack xt = 0x80
NIP  ( x1 x2 -- x1 ) discard 2nd item on stack xt = 0x4F
NOOP  ( -- ) does nothing xt = 0x1C5
R>DROP  ( x -- x ) drop cell from return stack xt = 0x57
2DROP  ( x1 x2 -- ) drop cell pair xt = 0x62
3DROP  ( x1 x2 x3 -- ) drop triple from stack xt = 0x198
2DUP  ( x1 x2 -- x1 x2 x1 x2 ) duplicate cell pair xt = 0x63
DUP  ( x -- x x ) duplicate top item xt = 0x20
?DUP  ( x -- x x | 0 ) duplicate top item if nonzero xt = 0x5E
CLEAR  ( -- ) empty the data stack xt = 0x18C
2SWAP  ( x1 x2 x3 x4 -- x3 x4 x1 x2 ) exchange top two cell pairs xt = 0x65
EXECUTECFA  ( addr -- ) execute at absolute address xt = 0x191
EXECUTE  ( xt -- ) execute at binding table location xt xt = 0xB9
PICK  ( ... n -- ... x[n] ) get nth stack element xt = 0x74
0 pick = dup, 1 dup = over, etc.
R>  ( -- x ) pop cell from return stack xt = 0x2D
2R>  ( -- d ) pop double from return stack xt = 0x7F
>R  ( x -- ) push cell to return stack xt = 0x2C
2>R  ( d -- ) push double to return stack xt = 0x7E
DROP  ( x1 x2 -- x1 ) remove item from stack xt = 0x21
ROT  ( abc -- bca) rotate third stack item to top xt = 0x71
-ROT  ( abc -- cab) rotate top to third stack item xt = 0x72
-PICK  ( ... x n -- ... ) store NOS to the TOSth element xt = 0x76
SWAP  ( x1 x2 -- x2 x1 ) swap top 2 cells xt = 0x22
TUCK  ( x1 x2 -- x2 x1 x2 ) tuck TOS under NOS xt = 0x7A

Memory

Name Stack Effect Summary Token
W@  ( addr -- w ) 16-bit fetch xt = 0x31
W!  ( w addr -- ) 16-bit store xt = 0x34
W@P  ( addr -- x ) 16bit fetch from program memory xt = 0x186
W!P  ( x addr -- ) 16bit store to program memory xt = 0x189
+!  ( n addr -- ) add n to the cell at addr xt = 0x79
!A+  ( x -- ) append cell to A stream xt = 0x3D
!R+  ( x -- ) append cell to R stream xt = 0x43
C!A+  ( x -- ) append char to A stream xt = 0x3F
( addr -- x ) cell fetch, MSB first xt = 0x32
( x addr -- ) cell store, MSB first xt = 0x35
C@  ( addr -- c ) char fetch xt = 0x30
C@P  ( addr -- c ) char fetch from program memory xt = 0x184
C!  ( c addr -- ) char store xt = 0x33
C!P  ( c addr -- ) char store to program memory xt = 0x187
DECR  ( addr -- ) decrement cell by 1 xt = 0x7D
2@  ( a -- x1 x2 ) double-cell fetch xt = 0x8F
2!  ( x1 x2 a -- ) double-cell store xt = 0x8E
@A  ( -- x ) fetch cell from A stream xt = 0x38
@R  ( -- x ) fetch cell from R stream xt = 0x40
C@A  ( -- c ) fetch char from A stream xt = 0x3A
@P  ( addr -- x ) fetch from program memory xt = 0x185
A@  ( -- addr ) get A register xt = 0x37
INCR  ( addr -- ) increment cell by 1 xt = 0x7C
LAY  ( addr c -- addr' ) lay a char to memory xt = 0x7B
B@@+P  ( a -- c ) lift byte from an input stream xt = 0x1A7
Assume the pointer will always be in RAM data space, data is in code space.
B@@+  ( a -- c ) lift byte from an input stream xt = 0x1A6
Assume the pointer will always be in RAM data space, data is in data space.
@A+  ( -- x ) lift cell from A stream xt = 0x39
@R+  ( -- x ) lift cell from R stream xt = 0x41
C@A+  ( -- c ) lift char from A stream xt = 0x3B
A!  ( addr -- ) set A register xt = 0x36
!A  ( x -- ) store cell to A stream xt = 0x3C
!R  ( x -- ) store cell to R stream xt = 0x42
C!A  ( x -- ) store char to A stream xt = 0x3E
OFF  ( addr -- ) store false to addr xt = 0x78
!P  ( x addr -- ) store to program memory xt = 0x188
ON  ( addr -- ) store true to addr xt = 0x77