diff options
| -rw-r--r-- | readme.md | 15 | ||||
| -rw-r--r-- | sanctuary.fs | 6 |
2 files changed, 21 insertions, 0 deletions
@@ -71,6 +71,10 @@ add u2 to u1. ### `+! ( a -- )` add one to the value at memory address a. +### `+to ( comp: "name" -- | intr: u "name" -- ) IMMEDIATE` +compile or execute (depending on `state`) code to add u to the contents +of a `value`. (in compile mode u is whatever was on the stack already.) + ### `, ( u -- )` write a 64 bit value to user memory and increment the user memory pointer. @@ -80,6 +84,10 @@ subtract u2 from u1. ### `-! ( a -- )` subtract one from the value at memory address a. +### `-to ( comp: "name" -- | intr: u "name" -- ) IMMEDIATE` +compile or execute (depending on `state`) code to subtract u from the contents +of a `value`. (in compile mode u is whatever was on the stack already.) + ### `-rot ( u1 u2 u3 -- u3 u1 u2 )` rotate the three topmost values on the stack so that the topmost value is moved to the third highest. @@ -441,6 +449,10 @@ conclude an if statement. ### `tib ( -- a )` a variable containing the address of the current input buffer. +### `to ( comp: "name" -- | intr: u "name" -- ) IMMEDIATE` +compile or execute (depending on `state`) code to modify the contents +of a `value`. + ### `true ( -- u )` a cell with all bits set. @@ -450,6 +462,9 @@ write u characters at a to output. ### `until ( ? -- ) IMMEDIATE COMPILE-ONLY` if the given flag is true, loop back to `begin`. +### `value ( u "name" -- )` +create a value called name, the initial value of which is u. + ### `variable ( "name" -- )` create a variable word, which yields an address that can be written and read. diff --git a/sanctuary.fs b/sanctuary.fs index ff4a266..6bdfbfc 100644 --- a/sanctuary.fs +++ b/sanctuary.fs @@ -44,6 +44,12 @@ : constant create , does> @ ; : variable create 1 cells allot ; +: value parse-name (header) latest ! postpone literal + [ hex ] c3 c, [ decimal ] ; \ c3 = RET +: to ' ( word ) 6 + state @ if postpone literal postpone ! else ! then ; immediate +: +to ' ( word ) 6 + state @ if postpone literal postpone +! else +! then ; immediate +: -to ' ( word ) 6 + state @ if postpone literal postpone -! else -! then ; immediate + 0 constant false -1 constant true bye |
