Compare commits
No commits in common. "274376a5de644fb368a5ed212a928a953cf5a8db" and "f91fa39aefc0a82391e42e4d9a72a2917acde4d5" have entirely different histories.
274376a5de
...
f91fa39aef
@ -1,9 +1,8 @@
|
|||||||
;; 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 eol 0)
|
(variable eom 1024)
|
||||||
|
;; 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)
|
||||||
@ -50,13 +49,9 @@ 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 -- )
|
||||||
@ -71,19 +66,19 @@ relocate-cons ;; (o -- )
|
|||||||
|
|
||||||
relocate-reg ;; (r -- )
|
relocate-reg ;; (r -- )
|
||||||
(dup)
|
(dup)
|
||||||
(push #x80000000) ;; Is this a cons?
|
(push cons?)
|
||||||
(and)
|
(call)
|
||||||
(push reg-relocated)
|
(push reg-relocated)
|
||||||
(if)
|
(if)
|
||||||
(dup)
|
(dup)
|
||||||
(ref eol)
|
(push eol?)
|
||||||
(=) ;; Is this eol?
|
(call)
|
||||||
(not)
|
(not)
|
||||||
(push reg-relocated)
|
(push reg-relocated)
|
||||||
(if)
|
(if)
|
||||||
(dup)
|
(dup)
|
||||||
(push #x40000000) ;; Is it a broken heart?
|
(push broken-heart?)
|
||||||
(and)
|
(call)
|
||||||
(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
|
||||||
@ -107,14 +102,9 @@ copy-and-construct
|
|||||||
(push 4)
|
(push 4)
|
||||||
(+)
|
(+)
|
||||||
(!)
|
(!)
|
||||||
(push #x40000000)
|
(dup) ;; Construct the broken heart
|
||||||
(over)
|
(push install-broken-heart)
|
||||||
(!)
|
(call)
|
||||||
(ref free)
|
|
||||||
(over)
|
|
||||||
(push 4)
|
|
||||||
(+)
|
|
||||||
(!)
|
|
||||||
(ref free) ;; Move free pointer
|
(ref free) ;; Move free pointer
|
||||||
(push 8)
|
(push 8)
|
||||||
(+)
|
(+)
|
||||||
@ -122,17 +112,5 @@ copy-and-construct
|
|||||||
reg-relocated
|
reg-relocated
|
||||||
(drop)
|
(drop)
|
||||||
(return)
|
(return)
|
||||||
|
|
||||||
main
|
main
|
||||||
;; These need to be initialized with the runtime
|
;; TODO
|
||||||
(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 ram-word-set! (cute vm-memory-set! vm <> <>))
|
||||||
(define debugger (vm-debugger vm))
|
(define debugger (vm-debugger vm))
|
||||||
(define exit? #f)
|
(define exit? #f)
|
||||||
(define (jump x) (vm-pc-set! vm (logand #x2fffffff x)))
|
(define (jump x) (vm-pc-set! vm x))
|
||||||
(define (fetch-byte)
|
(define (fetch-byte)
|
||||||
(let ([byte (ram-byte-ref (vm-pc vm))])
|
(let ([byte (ram-byte-ref (vm-pc vm))])
|
||||||
(vm-pc-set! vm (+ (vm-pc vm) 1))
|
(vm-pc-set! vm (+ (vm-pc vm) 1))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user