diff options
| -rw-r--r-- | readme.md | 22 | ||||
| -rw-r--r-- | sanctuary.fs | 13 |
2 files changed, 35 insertions, 0 deletions
@@ -263,6 +263,10 @@ yield the value of the first character of the next word in the input stream. copy u bytes of memory from a1 to a2. bytes are copied in low memory to high memory order. +### `cmove, ( a u -- )` +copy u bytes of memory from a1 to `here`, then increment `here` appropriately. +bytes are copied in low memory to high memory order. + ### `cmove> ( a1 a2 u -- )` copy u bytes of memory from a1 to a2. bytes are copied in high memory to low memory order. @@ -370,6 +374,9 @@ the most recently created word. ### `literal ( n -- ) IMMEDIATE COMPILE-ONLY` compile a push of the literal value n into the currently compiling word. +### `nip ( u1 u2 -- u2 )` +drop the second-highest value from the stack. + ### `number ( a u -- n -1 | 0 )` convert given string into a number along with a flag. if parsing a number fails then 0 (false) is returned @@ -413,6 +420,11 @@ in a begin-while-repeat loop, loop back to the condition. ### `rot ( u1 u2 u3 -- u2 u3 u1 )` rotate the top three values on the stack so that the third highest value is moved to the top. +### `s" ( "string" -- ) IMMEDIATE COMPILE-ONLY` +compile into the definition code to push the given string, +terminated by a double quote. +the string data and length are stored inline in the definition. + ### `smudge ( -- )` toggles the smudge bit on the xt in latest. @@ -421,6 +433,12 @@ a variable containing a boolean value. if 0 (false), the system is in interpreting mode, if -1 (true), the system is in compiling mode. +### `stderr ( -- 2 )` +push the file descriptor of stderr to the stack. + +### `stdout ( -- 1 )` +push the file descriptor of stdout to the stack. + ### `swap ( u1 u2 -- u2 u1 )` swap the two topmost values on the stack. @@ -456,6 +474,10 @@ of a `value`. ### `true ( -- u )` a cell with all bits set. +### `tuck ( u1 u2 -- u2 u1 u2 )` +place a copy of the highest value on the stack +below the second highest value on the stack. + ### `type ( a u -- )` write u characters at a to output. diff --git a/sanctuary.fs b/sanctuary.fs index 6bdfbfc..6bc19e1 100644 --- a/sanctuary.fs +++ b/sanctuary.fs @@ -6,6 +6,9 @@ : decimal 10 base ! ; : hex 16 base ! ; +: nip swap drop ; +: tuck swap over ; + : <mark here ; : <resolve here 4 + - d, ; : >mark here 0 d, ; @@ -52,4 +55,14 @@ 0 constant false -1 constant true + +: cmove, dup >r here swap cmove r> allot ; +: s" 1 >in +! [ char " ] literal parse ( a u ) + branch >mark >r 2dup cmove, nip ( u ) ( R: mark ) + r> dup >resolve 4 + ( u a ) + postpone literal ( a ) postpone literal ( u ) ; immediate compile-only + +1 constant stdout +2 constant stderr + bye |
