summaryrefslogtreecommitdiff
path: root/jefs.fs
diff options
context:
space:
mode:
Diffstat (limited to 'jefs.fs')
-rw-r--r--jefs.fs25
1 files changed, 24 insertions, 1 deletions
diff --git a/jefs.fs b/jefs.fs
index 65c2a99..26d4848 100644
--- a/jefs.fs
+++ b/jefs.fs
@@ -140,6 +140,11 @@ variable disp
: mov, rex, 8b c, modrm @ c, disp, asm$ ;
: lea, rex, 8d c, modrm @ c, disp, asm$ ;
: call, rex, ff c, /2 modrm @ c, disp, asm$ ;
+\ these use the mod/rm version which is technically a waste of space
+\ i think my register strategy was, Bad
+\ because +rd now just, doesn't work. without some jank i guess
+: push, rex, ff c, /6 modrm @ c, disp, asm$ ;
+: pop, rex, 8f c, /0 modrm @ c, disp, asm$ ;
decimal
\ }}}
@@ -148,8 +153,26 @@ decimal
rex.w r14, r14 8 d) lea,
r11 call, ] ;
+: rnip [ r13 pop, r12 pop, r10 pop, r12 push, r13 push, ] ;
+: rover [ r13 pop, r12 pop, r10 pop, r10 push, r12 push, r10 push, r13 push, ] ;
+: rswap [ r13 pop, r12 pop, r10 pop, r12 push, r10 push, r13 push, ] ;
+
: exit ret, ; immediate
+\ DO LOOP {{{
+: do ( RT: lim idx -- ) ( ? ) ' swap compile, ' >r compile, ' >r compile, <mark ; immediate
+\ TODO rework to avoid address of the word. maybe a rnip word?
+\ compiling: rover r> 1+ rnip rover rnip r> rnip 2dup >=
+\ swap >r rswap swap >r rswap [ ?branch <resolve ] rnip rnip
+: loop ( -- ) ' rover compile, ' r> compile, ' 1+ compile, ' rnip compile,
+ ' rover compile, ' rnip compile, ' r> compile, ' rnip compile,
+ ' 2dup compile, ' >= compile, ' swap compile, ' >r compile,
+ ' rswap compile, ' swap compile, ' >r compile, ' rswap compile,
+ ?branch <resolve ' rnip compile, ' rnip compile, ;
+: i r> r> dup >r swap >r ; \ todo fix to skip addr of `i`
+\ todo j
+\ }}}
+
: ?comp state @ 0<> if 3 error ! handler execute then ;
: ?intr state @ if 4 error ! handler execute then ;
@@ -359,7 +382,7 @@ make line-buffer line-buffer-length allot
: include ( "path" -- ) parse included ;
\ }}}
-\ ARGS {{{
+\ ARGS & ENVIRONMENT {{{
: argc rs0 @ @ ;
: argv ( n -- a u ) 1+ cells rs0 @ + @ dup strlen ; \ segfaults if n>=argc
: environ argc 2 + cells rs0 @ + ;