Compare commits
No commits in common. "1c84a9c86247ab5222d1c8158a10089aa63aa583" and "33f16189158b2eeea08790322f365b2a254c24d1" have entirely different histories.
1c84a9c862
...
33f1618915
@ -1,6 +1,3 @@
|
||||
(push main)
|
||||
(jmp)
|
||||
|
||||
;; Note that this is scheme syntax wrapping asm for a stack machine
|
||||
(variable eol 0)
|
||||
(variable scan 0)
|
||||
@ -11,6 +8,9 @@
|
||||
(variable new 0)
|
||||
(variable root 0)
|
||||
|
||||
(push main)
|
||||
(jmp)
|
||||
|
||||
alloc ;; ( -- p)
|
||||
;; Test if free will go beyond eom
|
||||
(ref free)
|
||||
@ -129,7 +129,7 @@ gc-loop
|
||||
(<)
|
||||
(branch gc-loop-done)
|
||||
(ref scan)
|
||||
(push relocate-reg)
|
||||
(relocate-reg)
|
||||
(push gc-loop)
|
||||
(jmp)
|
||||
gc-loop-done
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
(define (write-word word)
|
||||
(define bv (make-bytevector 4))
|
||||
(bytevector-u32-native-set! bv 0 word)
|
||||
(bytevector-s32-native-set! bv 0 word)
|
||||
(write-bytevector bv))
|
||||
|
||||
(define (assembly-pass seq labels)
|
||||
|
||||
10
scmvm/vm.scm
10
scmvm/vm.scm
@ -6,7 +6,6 @@
|
||||
#:use-module (srfi srfi-9)
|
||||
#:use-module (srfi srfi-26)
|
||||
#:use-module (srfi srfi-43)
|
||||
#:use-module (ice-9 format)
|
||||
#:export (make-stack (push . stack-push) (pop . stack-pop) (peek . stack-peek) stack-ref stack->list
|
||||
(make-vm* . make-vm) run-vm
|
||||
vm-memory-ref vm-memory-byte-ref vm-memory-set! vm-memory vm-load-program!
|
||||
@ -115,16 +114,12 @@
|
||||
(swap #x17)
|
||||
(rot #x18)
|
||||
(over #x19)
|
||||
(not #x1a)
|
||||
(bye #xff)))
|
||||
|
||||
(define instruction-code cadr)
|
||||
|
||||
(define (op-lookup code)
|
||||
(let ([op (find (lambda (x) (= (instruction-code x) code)) *instruction-set*)])
|
||||
(if op
|
||||
(car op)
|
||||
(error (format #f "tried to execute non-existant instruction ~x" code)))))
|
||||
(car (find (lambda (x) (= (instruction-code x) code)) *instruction-set*)))
|
||||
|
||||
(define (binop-lookup op)
|
||||
(case (op-lookup op)
|
||||
@ -134,8 +129,7 @@
|
||||
[(or) logior]
|
||||
[(nand) (compose lognot logand)]
|
||||
[(nor) (compose lognot logior)]
|
||||
[(xor) logxor]
|
||||
[(not) lognot]))
|
||||
[(xor) logxor]))
|
||||
|
||||
(define (relop-lookup op)
|
||||
(case (op-lookup op)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user