Compare commits
2 Commits
f91fa39aef
...
274376a5de
Author | SHA1 | Date | |
---|---|---|---|
274376a5de | |||
03fa8d4370 |
@ -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
|
||||
|
@ -164,7 +164,7 @@
|
||||
(define ram-word-set! (cute vm-memory-set! vm <> <>))
|
||||
(define debugger (vm-debugger vm))
|
||||
(define exit? #f)
|
||||
(define (jump x) (vm-pc-set! vm x))
|
||||
(define (jump x) (vm-pc-set! vm (logand #x2fffffff x)))
|
||||
(define (fetch-byte)
|
||||
(let ([byte (ram-byte-ref (vm-pc vm))])
|
||||
(vm-pc-set! vm (+ (vm-pc vm) 1))
|
||||
|
Loading…
Reference in New Issue
Block a user