Word List


Stack - Words for manipulating the stack
CLEAR DROP DUP OVER ROT -ROT SWAP

Math - Words for mathematical calculations
+ - * / ABS MAX MIN COS SIN TAN DEG PI

Logic - Words for bitwise logic operations
AND NOT OR XOR LS RS

Variables - Words for managing variables
VAR STO

Programming - Words for defining and controling programs
: ; EXIT HALT QUIT

Conditionals - Words for conditional program structures
= <> > < IF ELSE THEN

Loops - Words for loop structures
DO LOOP LEAVE I J K BEGIN AGAIN UNTIL

System - Words for low-level system access
! @ C! C@ ' EXEC FREE


Stack Words for manipulating the stack
Words: CLEAR DROP DUP OVER ROT -ROT SWAP
Sections: Stack Math Logic Variables Programming Conditionals Loops System


CLEAR
( a -- )
Types:
a
- float raw hex smart hex string
Works on any number of stack items.

Removes all items from the stack.

Example:
Before
After


Related words: DROP



DROP
( a -- )
Types:
a
- float raw hex smart hex string

Removes the first item on the stack.

Example:
Before
After


Related words: CLEAR



DUP
( a -- a a )
Types:
a
- float raw hex smart hex string

Duplicates the first item on the stack.

Example:
Before
After


Related words: OVER



OVER
( a b -- a b a )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string

Duplicates the second item on the stack.

Example:
Before
After


Related words: DUP



ROT
( a b c -- b c a )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string

Rotates first three stack items so that the third item is first on the stack.

Example:
Before
After


Related words: -ROT SWAP



-ROT
( a b c -- c a b )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string

Rotates first three stack items so that the first item is third on the stack.

Example:
Before
After


Related words: ROT SWAP



SWAP
( a b -- b a )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string

Swaps the first two stack items.

Example:
Before
After


Related words: ROT -ROT



Math Words for mathematical calculations
Words: + - * / ABS MAX MIN COS SIN TAN DEG PI
Sections: Stack Math Logic Variables Programming Conditionals Loops System


+
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be added to float, and raw hex to raw hex or smart hex, but two smart hex can't be added.

Adds the first two stack items together.

Example:
Before adding floats
After adding floats


Before adding hex
After adding hex


Related words: - * /



-
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be subtracted from float, and raw hex from raw hex or smart hex, but smart hex can't be subtracted from raw hex.

Subtracts the first stack item from the second one.

Example:
Before subtracting floats
After subtracting floats


Before subtracting hex
After subtracting hex


Related words: + * /



*
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be multipled with float, and raw hex with raw hex.

Multiplies the first two stack items.

Example:
Before multiplying floats
After multiplying floats


Before multiplying hex
After multiplying hex


Related words: + - /



/
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be divided by float, and raw hex by raw hex.

Divides the second stack item by the first one.

Example:
Before dividing floats
After dividing floats


Before dividing hex
After dividing hex


Dividing by zero results in an error


Related words: + - *



ABS
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string

Absolute value.

Example:
Before
After



MAX
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be compared to float, and hex can be compared to hex.

Compares the first two stack items and keeps the larger one.

Example:
Before finding max of floats
After finding max of floats


Before finding max of hex
After finding max of hex


Related words: MIN



MIN
( a b -- c )
Types:
a
b
b
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be compared to float, and hex can be compared to hex.

Compares the first two stack items and keeps the smaller one.

Example:
Before finding min of floats
After finding min of floats


Before finding min of hex
After finding min of hex


Related words: MAX



COS
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string
a is an angle in radians

Cosine. Argument must be between -PI/2 and PI/2 inclusive.

Example:
Before
After


Valid range: -PI/2 to PI/2


Related words: SIN TAN DEG PI



SIN
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string
a is an angle in radians

Sine. Argument must be between -PI/2 and PI/2 inclusive.

Example:
Before
After


Valid range: -PI/2 to PI/2


Related words: COS TAN DEG PI



TAN
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string
a is an angle in radians

Tangent. Argument must be between -PI/2 and PI/2.

Example:
Before
After


Valid range: between -PI/2 to PI/2


Related words: COS SIN DEG PI



DEG
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string

Converts an angle in degrees to radians.

Example:
Before
After


Related words: COS SIN TAN PI



PI
( -- a )
Types:
a
- float raw hex smart hex string

Pushes the value of pi onto the stack.

Example:
Before
After


Related words: COS SIN TAN DEG



Logic Words for bitwise logic operations
Words: AND NOT OR XOR LS RS
Sections: Stack Math Logic Variables Programming Conditionals Loops System


AND
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string

Bitwise AND of the first two stack items.

Example:
Before
After


Related words: NOT OR XOR



NOT
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string

Returns $FFFF if the first stack item is $0 and returns $0 if it's non-zero.

Example:
Before
After


Before
After


Related words: AND OR XOR



OR
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string

Bitwise OR of the first two stack items.

Example:
Before
After


Related words: AND NOT XOR



XOR
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string

Bitwise XOR of the first two stack items.

Example:
Before
After


Related words: AND NOT OR



LS
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string

Shifts the second item on the stack left by the number of bits given in the first item.

Example:
Before
After - $123 shifted left by 5 bits


Related words: RS



RS
( a b -- c )
Types:
a
b
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string

Shifts the second item on the stack right by the number of bits given in the first item.

Example:
Before
After - $2460 shifted right by 5 bits


Related words: LS



Variables Words for managing variables
Words: VAR STO
Sections: Stack Math Logic Variables Programming Conditionals Loops System


VAR
( -- )

Creates a new variable. STO also creates a new variable if it doesn't exist.

Example:
Creating the variable X
Fetching the value of X


Value of X


Related words: STO



STO
( a -- )
Types:
a
- float raw hex smart hex string

Stores the first item on the stack in the following variable. If the variable doesn't exist, it's created. Inside of a word definition, the variable must already exist before being used with STO. Pressing Shift+S produces the symbol 🡪 which is a shortcut for STO.

Example:
Storing 5 in X
Fetching the value of X


Value of X
Shift+S for 🡪 is also STO


Related words: VAR



Programming Words for defining and controling programs
Words: : ; EXIT HALT QUIT
Sections: Stack Math Logic Variables Programming Conditionals Loops System


:
( -- )

Defines a new word.

Example:
Defining a new word FOO
Before running FOO


After running FOO


Related words: ;



;
( -- )

Concludes the definition of a new word.

Example:
Defining a new word FOO
Before running FOO


After running FOO


Related words: :



EXIT
( -- )

Exits the currently executing word. Continues execution of calling word if it exists. Calling EXIT from inside a DO loop is safe. There is no UNLOOP word required before exiting a loop.
Compile-only word

Example:
Defining a new word FOO
Defining a word containing FOO


Running bar
FOO exits early. Bar continues running.


Related words: QUIT



HALT
( -- )

Halts the simulation.

Example:
Halting simulation



QUIT
( -- )

Exits the currently executing word and halts all execution.
Compile-only word

Example:
Defining a new word FOO
Defining a word containing FOO


Running bar
FOO quits, stopping all execution


Related words: EXIT



Conditionals Words for conditional program structures
Words: = <> > < IF ELSE THEN
Sections: Stack Math Logic Variables Programming Conditionals Loops System


=
( a b -- c )
Types:
a
a
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be compared to float, and hex can be compared to hex.

Compares the first item on the stack to the second item. Returns $FFFF if they are equal and $0000 if they aren't.

Example:
Before comparing floats
After comparing floats


Before comparing hex
After comparing hex


Related words: <> > < IF ELSE THEN



<>
( a b -- c )
Types:
a
a
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be compared to float, and hex can be compared to hex.

Compares the first item on the stack to the second item. Returns $FFFF if they are not equal and $0000 if they are.

Example:
Before comparing floats
After comparing floats


Before comparing hex
After comparing hex


Related words: = > < IF ELSE THEN



>
( a b -- c )
Types:
a
a
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be compared to float, and hex can be compared to hex.

Compares the first item on the stack to the second item. Returns $FFFF if the second is greater and $0000 if the first is greater.

Example:
Before comparing floats
After comparing floats


Before comparing hex
After comparing hex


Related words: = <> < IF ELSE THEN



<
( a b -- c )
Types:
a
a
c
- float raw hex smart hex string
- float raw hex smart hex string
- float raw hex smart hex string
Float can be compared to float, and hex can be compared to hex.

Compares the first item on the stack to the second item. Returns $FFFF if the second is less and $0000 if the first is less.

Example:
Before comparing floats
After comparing floats


Before comparing hex
After comparing hex


Related words: = <> > IF ELSE THEN



IF
( a -- )
Types:
a
- float raw hex smart hex string

Tests the first item on the stack and skips to THEN if false.
Compile-only word

Example:
First, define a new word FOO:

: FOO DUP 20 > IF 1.1 * THEN ;

Defining FOO (partial view)


DUP makes a copy of the first item on the stack. > compares the item to 20. If larger than 20, it's multiplied by 1.1. If not, the steps between IF and THEN are skipped.

Before
After


Related words: = <> > < ELSE THEN



ELSE
( -- )

Marks an alternative block to be executed if an IF statement is false.
Must come between IF and THEN.
Compile-only word

Example:
First, define a new word FOO:

: FOO 18 < IF "CHILD" ELSE "ADULT" THEN ;

Defining FOO (partial view)


FOO compares the first item on the stack to 18. If it's less, the string "CHILD" is pushed onto the stack. Otherwise, "ADULT" is pushed onto the stack.

Before
After


Before
After


Related words: = <> > < IF THEN



THEN
( -- )

Marks the end of a conditional block begun by IF.
Compile-only word

Example:
First, define a new word FOO:

: FOO DUP 20 > IF 1.1 * THEN ;

Defining FOO (partial view)


DUP makes a copy of the first item on the stack. > compares the item to 20. If larger than 20, it's multiplied by 1.1. If not, the steps between IF and THEN are skipped.

Before
After


Related words: = <> > < IF ELSE



Loops Words for loop structures
Words: DO LOOP LEAVE I J K BEGIN AGAIN UNTIL
Sections: Stack Math Logic Variables Programming Conditionals Loops System


DO
( a b -- )
Types:
a
a
- float raw hex smart hex string
- float raw hex smart hex string

Loops from the first value on the stack up to but not including the second value on the stack. Four levels of nested DO loops are supported. Calling EXIT from inside a DO loop is safe. There is no UNLOOP word required before exiting a loop. Press ESC to exit the loop early and halt execution.
Compile-only word

Example:
Defining FOO
Before


After


Related words: LOOP I J K LEAVE



LOOP
( a b -- )
Types:
a
a
- float raw hex smart hex string
- float raw hex smart hex string

Marks the end of a loop begun with DO. Four levels of nested DO loops are supported. Calling EXIT from inside a DO loop is safe. There is no UNLOOP word required before exiting a loop. Press ESC to exit the loop early and halt execution.
Compile-only word

Example:
A word with a DO loop
Before


After


Related words: DO I J K LEAVE



LEAVE
( -- )

Breaks out of a DO loop.
Compile-only word

Example:
First, define a new word FOO with a DO loop:

: FOO 0 8 1 DO I + I 4 = IF LEAVE THEN LOOP ;

Defining FOO (partial view)


FOO pushes a 0 on the stack to use as a counter. DO iterates from 1 to 7. I + adds the loop value to the counter on the stack. I 4 = compares the loop value to 4, and when it's equal, LEAVE exits the loop. As a result, FOO sums the values from 1 to 4 and exits the loop without summing 5, 6, or 7.




I
( -- )

Pushes the loop value of the innermost DO loop onto the stack.
Compile-only word

Example:
A word with a DO loop
Before - looping from 0 to 3


After


Related words: DO LOOP J K LEAVE



J
( -- )

Pushes the loop value of a second-level DO loop onto the stack.
Compile-only word

Example:
First, define a new word FOO with two nested DO loops:

: FOO 9 7 DO 5 3 DO I J * LOOP LOOP ;

Defining FOO (partial view)


The outer DO loop iterates from 7 to 8 and the inner loop iterates from 3 to 4. The first time through, I pushes 3 onto the stack and J pushes 7. * link multiplies the two values together and leaves 21 on the stack. The next iterations push the results of 4*7, 3*8, and 4*8.



Related words: DO LOOP I K LEAVE



K
( -- )

Pushes the loop value of a third-level DO loop onto the stack.
Compile-only word

Example:
First, define a new word FOO with three nested DO loops:

: FOO 9 8 DO 7 6 DO 5 3 DO I J * K + LOOP LOOP LOOP ;

Defining FOO (partial view)


The outer DO loop iterates only once with the value of 8 and the second-level loop iterates once with the value 6. (Loops usually iterate more than once, but these are kept short for example's sake.) The innermost loop iterates from 3 to 4. The first time through, I pushes 3 onto the stack and J pushes 6. * multiplies the two values together yielding 18. K pushes 8 onto the stack and + adds 8 to 18 leaving 26 on the stack. The next iteration pushes the result of 4*6+8.



Related words: DO LOOP I J LEAVE



BEGIN
( -- )

Marks the beginning of a BEGIN/AGAIN infinite loop or the beginning of a BEGIN/UNTIL conditional loop. Press ESC to exit the loop early and halt execution.
Compile-only word

Example:
First, define a new word FOO with an infinite BEGIN/AGAIN loop:

: FOO BEGIN 1 + AGAIN ;

Defining FOO (partial view)


Running FOO will add one to the first item on the stack continuously until ESC is pressed halting execution. EXIT and QUIT will also exit a BEGIN/AGAIN loop.

Before running FOO
After running FOO then pressing ESC


Next, define a new word BAR with a conditional BEGIN/UNTIL loop:

: BAR BEGIN $1 + DUP $50 = UNTIL ;

Defining BAR (partial view)


Running BAR will add $1 to the first item on the stack until it's equal to $50. Pressing ESC or executing EXIT or QUIT will exit a BEGIN/UNTIL loop early.

Before running BAR
After running BAR


Related words: AGAIN UNTIL EXIT QUIT



AGAIN
( -- )

Marks the end of an infinite loop begun with BEGIN. Press ESC to exit the loop early and halt execution.
Compile-only word

Example:
First, define a new word FOO with a BEGIN/AGAIN loop:

: FOO BEGIN 1 + AGAIN ;

Defining FOO (partial view)


Running FOO will add one to the first item on the stack continuously until ESC is pressed halting execution. EXIT and QUIT will also exit a BEGIN/AGAIN loop.

Before running FOO
After running FOO then pressing ESC


Related words: BEGIN UNTIL EXIT QUIT



UNTIL
( a -- )
Types:
a
- float raw hex smart hex string

Marks the end of a conditional loop begun with BEGIN. Press ESC to exit the loop early and halt execution.
Compile-only word

Example:
First, define a new word BAR with a conditional BEGIN/UNTIL loop:

: BAR BEGIN $1 + DUP $50 = UNTIL ;

Defining BAR (partial view)


Running BAR will add $1 to the first item on the stack until it's equal to $50. Pressing ESC or executing EXIT or QUIT will exit a BEGIN/UNTIL loop early.

Before running BAR
After running BAR


Related words: BEGIN AGAIN EXIT QUIT



System Words for low-level system access
Words: ! @ C! C@ ' EXEC FREE
Sections: Stack Math Logic Variables Programming Conditionals Loops System


!
( a b -- )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string
  • To store values in variables, use STO instead. Only use ! for low-level system access.
  • If value to be written is smart hex, it will not be automatically updated during garbage collection after being written!

Stores the second stack item at the address pointed to by the first stack item.

Example:
Drawing pixels to the screen


In this example, ! stores the 16-bit value $2003 at address $8080, which is mapped to two pixels at the center of the screen in the simulator as shown above. Since each pixel is mapped to one byte, storing $2003 writes $03 (the code for red) to the first pixel and $20 (the code for dark blue) to the following pixel. HALT pauses the simulation here so that the pixels are visible before the screen is redrawn.


Related words: @ C@ C!



@
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string
To fetch values from variables, use the name of the variable instead of @. Only use @ for low-level system access.

Fetches the 16-bit value pointed to by the first stack item.

Example:
Before
After - 16-bit value fetched from $1234


Related words: ! C@ C!



C!
( a b -- )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string
  • To store values in variables, use STO instead. Only use C! for low-level system access.
  • If value to be written is smart hex, it will not be automatically updated during garbage collection after being written!

Stores the low byte of the second stack item at the address pointed to by the first stack item.

Example:
Drawing a red pixel to the screen


In this example, C! stores the 8-bit value $03 (the code for red) at address $8080, which is mapped to the pixel at the center of the screen in the simulator as shown above. HALT pauses the simulation here so that the pixels are visible before the screen is redrawn.


Related words: C@ @ !



C@
( a -- b )
Types:
a
b
- float raw hex smart hex string
- float raw hex smart hex string
To fetch values from variables, use the name of the variable instead of C@. Only use C@ for low-level system access.

Fetches the 8-bit value pointed to by the first stack item.

Example:
Before
After - 8-bit value fetched from $1234


Related words: C! @ !



'
( -- a )
Types:
a
- float raw hex smart hex string

Fetches the address of the following word, which can be built-in (ie primitive) or user-defined (ie secondary).

Example:
Before
After - address of DUP


Before
After


Related words: EXEC



EXEC
( a -- )
Types:
a
- float raw hex smart hex string

Executes the word pointed to by the first stack item. The word can be built-in (ie primitve) or user-defined (ie secondary).

Example:
Before
After


Related words: '



FREE
( -- a )
Types:
a
- float raw hex smart hex string

Pushes the number of free bytes of RAM onto the stack.

Example:
Before
After