Instructions set
Please note than although most of the instructions documented here are built-in, some of them are implemented in FORTH. To use them, you’ll need to type the "HI" command before.
Arithmetic operations
+
Stack: n1 n2 —> n3
Post: n3=n1+n2
Pops the two top numbers from the main stack, apply the "plus" operator and pushes back the result.
-
Stack: n1 n2 —> n3
Post: n3=n1-n2
Pops the two top numbers from the main stack, apply the minus operator and pushes back the result.
*
Stack: n1 n2 —> n3
Post: n3=n1*n2
Pops the two top numbers from the main stack, apply the star operator and pushes back the result.
/
Stack n1 n2 —> n3
Pre: n2>0
Post: n3=n1/n2
Pops the two top numbers from the main stack, apply the slash operator and pushes back the result.
/MOD
Stack: n1 n2 —> n3 n4
Pre: n2>0
Post: n3=n1/n2 and n4=n1 mod n2
Pops the two top numbers from the main stack, and then pushes back the result of the slash operation as well as the result of the MOD operation.
*/
Stack: n1 n2 n3 —> n4
Pre: n3>0
Post: n4=(n1*n2)/n3
Pops the three top numbers from the main stack, then apply the star operator to the top two, followed by the slash operator with help of the third number.
MOD
Stack: n1 n2 —> n3
Pre: n2>0
Post: n3=n1 mod n2
Pops the two top numbers from the main stack, apply the mod operator and then pushed back the result.
NEGATE
Stack: n1 —> n2
Post: n2=-n1
Pops a number from the main stack, and pushes back its negation.
Conditions tests
=
<
>
<>
>=
<=
Logical operators
AND
OR
NOT
Stack operations
DROP
2DROP
DUP
2DUP
OVER
ROT
SWAP
NIP
MAX
MIN
Numeric I/O
.
.S
Numeric bases
BASE
HEX
DECIMAL
BIN
OCT
Character I/O
EMIT
KEY
CR
."
File
HI
LOAD
Conditional statements and loops
IF ELSE THEN
BEGIN WHILE REPEAT
Variables declaration
INT
—>
INT-ARRAY
[ ]
Command declaration
: ;
Error handling
ABORT
In the same section
Stay tuned!
What others think
«Hi, I have been using gUSB with my i-Bead 100 portable USB player for some time now and find it very useful. Well done!»
Darren