summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jefs.fs12
-rw-r--r--jefs.s6
2 files changed, 14 insertions, 4 deletions
diff --git a/jefs.fs b/jefs.fs
index 0f4a282..f53f219 100644
--- a/jefs.fs
+++ b/jefs.fs
@@ -24,9 +24,6 @@ decimal
: constant create [compile] lit ret, ;
: variable 1 cells allot create [compile] lit ret, ;
-32 constant bl
-: space bl emit ;
-
\ TODO interpret mode strings?
: s" [ char " ] literal 1 >in +! ( skip spc ) [compile] litstring ; immediate
: ." [compile] s" ' say compile, ; immediate \ lol this word breaks the highlighting, here have another "
@@ -45,12 +42,18 @@ decimal
: if 0branch >mark ; immediate ( I: -- a )
: else branch >mark swap >resolve ; immediate
: then >resolve ; immediate
+: while 0branch >mark ; immediate
+: repeat branch swap <resolve >resolve ; immediate
: / /mod swap drop ;
: mod /mod drop ;
: negate 0 swap - ;
: abs dup 0< if negate then ;
+32 constant bl
+: space bl emit ;
+: spaces begin dup 0> while space 1- repeat drop ;
+
\ PNO
\ mostly from pforth
255 allot variable pad
@@ -64,10 +67,11 @@ variable hld
: (u.) <# #s #> ;
: u. (u.) say space ;
+: u.r >r (u.) r> over - spaces say ;
: (.) dup abs <# #s swap sign #> ;
: . (.) say space ;
-
\ TODO something is leaking its stack (a word address i think)
+15 10 u.r
t
bye
diff --git a/jefs.s b/jefs.s
index 03dd963..da26f5e 100644
--- a/jefs.s
+++ b/jefs.s
@@ -700,13 +700,17 @@ defword "-rot", dash_rot, 0
ret
defword "r>", from_r, 0
+ pop r12 ; keep return address
pop r11
pspush r11
+ push r12
ret
defword ">r", to_r, 0
+ pop r12 ; ret addr
pspop r11
push r11
+ push r12
ret
defword "drop", drop, 0
@@ -719,7 +723,9 @@ defword "2drop", twodrop, 0
ret
defword "rdrop", rdrop, 0
+ pop r12 ; ret addr
pop r11
+ push r12
ret
; not sure if this is the right place to put this but