diff options
| author | kitty <nepeta@canaglie.net> | 2026-03-12 14:30:27 +1100 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-03-12 14:30:27 +1100 |
| commit | 41af0f7a1f4d0754d92dfc34917a18a23e01697d (patch) | |
| tree | 64e8873cf163b96bcb859ba76bcbfceefb05896e | |
| parent | c7b225fa133e3632159c9dc1d22f88461760df1e (diff) | |
not working yet DO LOOP
| -rw-r--r-- | jefs.fs | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -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 @ + ; |
