From aa1061032d57667c5b53ab445b7942f3bbf6f681 Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 16 Feb 2026 23:40:35 +1100 Subject: jonesforth port improvements of stack words --- jefs.fs | 6 +++++- jefs.s | 17 +++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/jefs.fs b/jefs.fs index c37067d..8bfb336 100644 --- a/jefs.fs +++ b/jefs.fs @@ -7,12 +7,16 @@ : decimal 10 base ! ; : hex 16 base ! ; +hex +: ret, c3 c, ; +decimal + : 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) -: constant create [compile] lit 195 ( ret ) c, ; +: constant create [compile] lit ret, ; : begin here @ ; immediate : again branch here @ 4 + - d, ; immediate \ add 4 to get to beginning of the next instruction diff --git a/jefs.s b/jefs.s index f5c2858..adede03 100644 --- a/jefs.s +++ b/jefs.s @@ -582,20 +582,14 @@ defword "syscall3", syscall3, 0 ; ( rdx rsi rdi id -- rax ) ret ; stack {{{ -; these stack wrangling words are dreadfully inefficient right now -; i will come back and make these less terrible later defword "dup", dup, 0 mov r11, [r14] pspush r11 ret defword "2dup", twodup, 0 ; ( a b -- a b a b ) - ; todo inefficient - pspop r11 - pspop r12 - - pspush r12 - pspush r11 + mov r11, [r14] + mov r12, [r14+8] pspush r12 pspush r11 ret @@ -609,12 +603,7 @@ defword "swap", swap, 0 ret defword "over", over, 0 - ; TODO inefficient (use r14 ptr arith to only push once) - pspop r11 - pspop r12 - - pspush r11 - pspush r12 + mov r11, [r14+8] pspush r11 ret -- cgit v1.2.3