forth: SP@ / SP! (+4; Hayes 174/590)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 21:07:10 +00:00
parent acf9c273a2
commit 387a6e7f5d
5 changed files with 42 additions and 3 deletions

View File

@@ -393,6 +393,19 @@
(s)
(let ((a (forth-peek s))) (when (not (= a 0)) (forth-push s a)))))
(forth-def-prim! state "DEPTH" (fn (s) (forth-push s (forth-depth s))))
(forth-def-prim! state "SP@" (fn (s) (forth-push s (forth-depth s))))
(forth-def-prim!
state
"SP!"
(fn
(s)
(let
((n (forth-pop s)))
(let
((cur (forth-depth s)))
(when
(> cur n)
(dict-set! s "dstack" (drop (get s "dstack") (- cur n))))))))
(forth-def-prim!
state
"PICK"