forth: BASE/DECIMAL/HEX/BIN/OCTAL (+9; 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:
@@ -18,8 +18,8 @@
|
||||
(dict-set! s "output" "")
|
||||
(dict-set! s "compiling" false)
|
||||
(dict-set! s "current-def" nil)
|
||||
(dict-set! s "base" 10)
|
||||
(dict-set! s "vars" (dict))
|
||||
(dict-set! (get s "vars") "base" 10)
|
||||
(dict-set! s "cstack" (list))
|
||||
(dict-set! s "mem" (dict))
|
||||
(dict-set! s "here" 0)
|
||||
@@ -538,6 +538,23 @@
|
||||
(> n 0)
|
||||
(for-each (fn (_) (forth-emit-str s " ")) (range 0 n))))))
|
||||
(forth-def-prim! state "BL" (fn (s) (forth-push s 32)))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"DECIMAL"
|
||||
(fn (s) (dict-set! (get s "vars") "base" 10)))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"HEX"
|
||||
(fn (s) (dict-set! (get s "vars") "base" 16)))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"BIN"
|
||||
(fn (s) (dict-set! (get s "vars") "base" 2)))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"OCTAL"
|
||||
(fn (s) (dict-set! (get s "vars") "base" 8)))
|
||||
(forth-def-prim! state "BASE" (fn (s) (forth-push s "base")))
|
||||
(forth-def-prim! state "I" (fn (s) (forth-push s (forth-rpeek s))))
|
||||
(forth-def-prim!
|
||||
state
|
||||
|
||||
Reference in New Issue
Block a user