MakoForth is a small Forth dialect which should be moderately familiar to anyone who has been exposed to ANS-Forth. The major notable differences are the use of # as line comments, loop...(break)...again|until|while looping constructs and the inclusion of syntax for inline double-quoted string constants. Cells are always 32-bit two’s complement signed integers.
a,b and n are signed 32-bit numbers (or any value)str is the address of a null (0) terminated stringf is a bit-flag- 0 for false and -1 for trueaddr generally refers to an addressWords with starred stack effects are immediate and will execute when encountered rather than being compiled.
+ ( a b -- n ) add a to b- ( a b -- n ) subtract b from a* ( a b -- n ) multiply a by b/ ( a b -- n ) divide a by bmod ( a b -- n ) compute the modulus of a by band ( a b -- n ) bitwise andor ( a b -- n ) bitwise orxor ( a b -- n ) bitwise xornot ( a -- n ) bitwise not< ( a b -- f ) is a less than b?> ( a b -- f ) is a greater than b?! ( n addr -- ) write value n to an address in memory@ ( addr -- n ) read a value from an address in memorydup ( a -- a a ) duplicate the top stack elementover ( a b -- a b a ) duplicate the second stack elementdrop ( a -- ) discard the top stack elementswap ( a b -- b a ) exchange the top stack elements>r ( n -- ) move the top stack element to the rstackr> ( -- n ) move the top rstack element to the stacki ( -- n ) copy the top rstack element to the stackj ( -- n ) copy the second rstack element to the stackhere ( -- addr ) obtain the address of a var containing the end of the dictionarymode ( -- f ) obtain true if compiling, false if interpreting, ( n -- ) append a value to the dictionary and advance here] ( -- ) switch to compiling mode[ ( -- )* switch to interpreting modeimmediate ( -- ) make the last defined word immediateliteral ( n -- )* compile a constant on the stack into the dictionary definitioncreate ( -- ) read a name from the input stream and make a new dictionary entryexit ( -- )* compile a return but stay in compiling mode: ( -- ) essentially create ]- define a procedure; ( -- )* terminate the current dictionary definitionif ( -- )* compile an if (takes an argument from the stack)then ( -- )* complete an if statement.else ( -- )* place between if and then optionallyloop ( -- )* create the head of a loopagain ( -- )* complete a loop and branch back unconditionallywhile ( -- )* complete a loop and branch back if a stack value is trueuntil ( -- )* complete a loop and branch back if a stack value is falsebreak ( -- )* unconditionally exit the current loop' ( -- )* compile a literal giving the address of a named worddoes> ( -- ) assign the remainder of this definition as behavior for the current word. ( n -- ) print a signed number followed by a spacespace ( -- ) print a spacecr ( -- ) print a carriage returntype ( str -- ) print a stringtypeln ( str -- ) print a string and a carriage returnforget ( -- ) read a name and forget it and all following wordsfree ( -- ) print remaining free dictionary spacesee ( -- ) read a name and print a dissassembly of that word# ( -- )* ignore input until a newline- line comment( ( -- )* ignore input until a )- block commentstack ( -- ) print the contents of the stackwords ( -- ) print a list of all dictionary entries