forth: SP@ / SP! (+4; Hayes 174/590)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user