From 5668025b71f63f4cfbc8d6341c220bae187fd593 Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 20 Feb 2026 23:31:26 +1100 Subject: two spaces for : --- jefs.fs | 90 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'jefs.fs') diff --git a/jefs.fs b/jefs.fs index 0bc6c99..0f4a282 100644 --- a/jefs.fs +++ b/jefs.fs @@ -1,71 +1,71 @@ -: cell+ 8 + ; -: syswrite ( u c-addr fd -- n ) 1 syscall3 ; -: say ( c-addr u -- ) swap 2 syswrite drop ; -: emit ( chr -- ) sp cell+ 1 swap 1 syswrite 2drop ; -: cr 10 emit ; +: cell+ 8 + ; +: syswrite ( u c-addr fd -- n ) 1 syscall3 ; +: say ( c-addr u -- ) swap 2 syswrite drop ; +: emit ( chr -- ) sp cell+ 1 swap 1 syswrite 2drop ; +: cr 10 emit ; -: decimal 10 base ! ; -: hex 16 base ! ; +: decimal 10 base ! ; +: hex 16 base ! ; -: nip swap drop ; -: tuck swap over ; +: nip swap drop ; +: tuck swap over ; hex -: ret, c3 c, ; +: ret, c3 c, ; decimal -: cells 8 * ; -: allot here @ swap here +! ; +: cells 8 * ; +: allot here @ swap here +! ; -: [compile] parse find drop >cfa compile, ; immediate -: ' parse find drop >cfa [compile] lit ; immediate \ note: no error handling (yet) -: recurse latest @ >cfa compile, ; immediate -: literal [compile] lit ; immediate -: constant create [compile] lit ret, ; -: variable 1 cells allot create [compile] lit ret, ; +: [compile] parse find drop >cfa compile, ; immediate +: ' parse find drop >cfa [compile] lit ; immediate \ note: no error handling (yet) +: recurse latest @ >cfa compile, ; immediate +: literal [compile] lit ; immediate +: constant create [compile] lit ret, ; +: variable 1 cells allot create [compile] lit ret, ; 32 constant bl -: space bl emit ; +: 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 " +: s" [ char " ] literal 1 >in +! ( skip spc ) [compile] litstring ; immediate +: ." [compile] s" ' say compile, ; immediate \ lol this word breaks the highlighting, here have another " \ forth83 (got them from pforth tho ehehe) \ < backward jump > forward jump \ adding/subtracting 4 gets to the next instruction. -: mark here @ 0 d, ; -: >resolve dup here @ swap - 4 - swap d! ; +: mark here @ 0 d, ; +: >resolve dup here @ swap - 4 - swap d! ; -: begin mark ; immediate ( I: -- a ) -: else branch >mark swap >resolve ; immediate -: then >resolve ; immediate +: begin mark ; immediate ( I: -- a ) +: else branch >mark swap >resolve ; immediate +: then >resolve ; immediate -: / /mod swap drop ; -: mod /mod drop ; -: negate 0 swap - ; -: abs dup 0< if negate then ; +: / /mod swap drop ; +: mod /mod drop ; +: negate 0 swap - ; +: abs dup 0< if negate then ; \ PNO \ mostly from pforth 255 allot variable 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 - ; +: <# 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 - ; -: (u.) <# #s #> ; -: u. (u.) say space ; -: (.) dup abs <# #s swap sign #> ; -: . (.) say space ; +: (u.) <# #s #> ; +: u. (u.) say space ; +: (.) dup abs <# #s swap sign #> ; +: . (.) say space ; \ TODO something is leaking its stack (a word address i think) -- cgit v1.2.3