WIP? written but untested runtime code

This commit is contained in:
Dane Johnson 2025-08-22 19:10:18 -05:00
parent 03fa8d4370
commit 274376a5de

View File

@ -1,8 +1,9 @@
;; Note that this is scheme syntax wrapping asm for a stack machine
(variable eom 1024)
;; These need to be initialized with the runtime
(variable eol 0)
(variable scan 0)
(variable free 0)
;; These need to be initialized with the runtime
(variable eom 0)
(variable old 0)
(variable new 0)
(variable root 0)
@ -49,9 +50,13 @@ gc-run ;; ( -- )
(call)
; Flip old and new
(ref old)
(dup)
(ref new)
(set! old)
(set! new)
(push 512)
(+)
(set! eom)
(return)
relocate-cons ;; (o -- )
@ -66,19 +71,19 @@ relocate-cons ;; (o -- )
relocate-reg ;; (r -- )
(dup)
(push cons?)
(call)
(push #x80000000) ;; Is this a cons?
(and)
(push reg-relocated)
(if)
(dup)
(push eol?)
(call)
(ref eol)
(=) ;; Is this eol?
(not)
(push reg-relocated)
(if)
(dup)
(push broken-heart?)
(call)
(push #x40000000) ;; Is it a broken heart?
(and)
(push copy-and-construct)
(if)
(dup) ;; Broken heart, copy updated address from cdr
@ -102,9 +107,14 @@ copy-and-construct
(push 4)
(+)
(!)
(dup) ;; Construct the broken heart
(push install-broken-heart)
(call)
(push #x40000000)
(over)
(!)
(ref free)
(over)
(push 4)
(+)
(!)
(ref free) ;; Move free pointer
(push 8)
(+)
@ -112,5 +122,17 @@ copy-and-construct
reg-relocated
(drop)
(return)
main
;; TODO
;; These need to be initialized with the runtime
(push memory)
(dup)
(set! new)
(push 512)
(+)
(dup)
(set! eom)
(set! old)
;; TODO set up root
memory