WIP? written but untested runtime code
This commit is contained in:
parent
03fa8d4370
commit
274376a5de
@ -1,8 +1,9 @@
|
|||||||
;; Note that this is scheme syntax wrapping asm for a stack machine
|
;; Note that this is scheme syntax wrapping asm for a stack machine
|
||||||
(variable eom 1024)
|
(variable eol 0)
|
||||||
;; These need to be initialized with the runtime
|
|
||||||
(variable scan 0)
|
(variable scan 0)
|
||||||
(variable free 0)
|
(variable free 0)
|
||||||
|
;; These need to be initialized with the runtime
|
||||||
|
(variable eom 0)
|
||||||
(variable old 0)
|
(variable old 0)
|
||||||
(variable new 0)
|
(variable new 0)
|
||||||
(variable root 0)
|
(variable root 0)
|
||||||
@ -49,9 +50,13 @@ gc-run ;; ( -- )
|
|||||||
(call)
|
(call)
|
||||||
; Flip old and new
|
; Flip old and new
|
||||||
(ref old)
|
(ref old)
|
||||||
|
(dup)
|
||||||
(ref new)
|
(ref new)
|
||||||
(set! old)
|
(set! old)
|
||||||
(set! new)
|
(set! new)
|
||||||
|
(push 512)
|
||||||
|
(+)
|
||||||
|
(set! eom)
|
||||||
(return)
|
(return)
|
||||||
|
|
||||||
relocate-cons ;; (o -- )
|
relocate-cons ;; (o -- )
|
||||||
@ -66,19 +71,19 @@ relocate-cons ;; (o -- )
|
|||||||
|
|
||||||
relocate-reg ;; (r -- )
|
relocate-reg ;; (r -- )
|
||||||
(dup)
|
(dup)
|
||||||
(push cons?)
|
(push #x80000000) ;; Is this a cons?
|
||||||
(call)
|
(and)
|
||||||
(push reg-relocated)
|
(push reg-relocated)
|
||||||
(if)
|
(if)
|
||||||
(dup)
|
(dup)
|
||||||
(push eol?)
|
(ref eol)
|
||||||
(call)
|
(=) ;; Is this eol?
|
||||||
(not)
|
(not)
|
||||||
(push reg-relocated)
|
(push reg-relocated)
|
||||||
(if)
|
(if)
|
||||||
(dup)
|
(dup)
|
||||||
(push broken-heart?)
|
(push #x40000000) ;; Is it a broken heart?
|
||||||
(call)
|
(and)
|
||||||
(push copy-and-construct)
|
(push copy-and-construct)
|
||||||
(if)
|
(if)
|
||||||
(dup) ;; Broken heart, copy updated address from cdr
|
(dup) ;; Broken heart, copy updated address from cdr
|
||||||
@ -102,9 +107,14 @@ copy-and-construct
|
|||||||
(push 4)
|
(push 4)
|
||||||
(+)
|
(+)
|
||||||
(!)
|
(!)
|
||||||
(dup) ;; Construct the broken heart
|
(push #x40000000)
|
||||||
(push install-broken-heart)
|
(over)
|
||||||
(call)
|
(!)
|
||||||
|
(ref free)
|
||||||
|
(over)
|
||||||
|
(push 4)
|
||||||
|
(+)
|
||||||
|
(!)
|
||||||
(ref free) ;; Move free pointer
|
(ref free) ;; Move free pointer
|
||||||
(push 8)
|
(push 8)
|
||||||
(+)
|
(+)
|
||||||
@ -112,5 +122,17 @@ copy-and-construct
|
|||||||
reg-relocated
|
reg-relocated
|
||||||
(drop)
|
(drop)
|
||||||
(return)
|
(return)
|
||||||
|
|
||||||
main
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user