summaryrefslogtreecommitdiff
path: root/sanctuary.fs
diff options
context:
space:
mode:
Diffstat (limited to 'sanctuary.fs')
-rw-r--r--sanctuary.fs23
1 files changed, 22 insertions, 1 deletions
diff --git a/sanctuary.fs b/sanctuary.fs
index 15d5a0e..1aab4e2 100644
--- a/sanctuary.fs
+++ b/sanctuary.fs
@@ -111,6 +111,21 @@ decimal
: munmap 11 syscall2 ;
\ }}}
+\ NUMERIC OUTPUT {{{
+\ this buffer is also used as a temporary string buffer.
+255 constant #pad
+create pad 255 cells allot
+: pad$ pad #pad + ;
+variable hld
+
+: <# pad$ hld ! ;
+: hold 1 hld -! ( chr ) hld @ c! ;
+: sign 0< if [ char - ] literal hold then ;
+: # base @ /mod swap 9 over < if 7 + then [ char 0 ] literal + hold ;
+: #s begin # dup 0= until ;
+: #> drop hld @ pad$ over - ;
+\ }}}
+
\ I/O {{{
0 constant stdin
1 constant stdout
@@ -118,9 +133,15 @@ decimal
: sys-write 0 syscall3 ;
: sys-read 1 syscall3 ;
+: sys-open 2 syscall3 ;
+: sys-close 3 syscall1 ;
-: type swap stdout 1 syscall3 drop ;
+: type swap stdout sys-read drop ;
: emit sp 1 type drop ;
+
+0 constant r/o
+1 constant w/o
+2 constant r/w
\ }}}
bye