summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-02-16 23:40:35 +1100
committerkitty <nepeta@canaglie.net>2026-02-16 23:41:05 +1100
commitaa1061032d57667c5b53ab445b7942f3bbf6f681 (patch)
tree6a4da5a9b4e15a5d15062d2565fd07bb2eb98cfb
parent11ab7360e32aebf5dfc5a1331ebe44b0ceff6354 (diff)
jonesforth port improvements of stack words
-rw-r--r--jefs.fs6
-rw-r--r--jefs.s17
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