Debugger, begin runtime stuff
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#:use-module (rnrs io ports)
|
||||
#:use-module ((scheme base)
|
||||
#:select (write-u8 write-bytevector))
|
||||
#:export (assemble assemble-file))
|
||||
#:export (assemble))
|
||||
|
||||
(define (lookup-instruction inst)
|
||||
(define inst-obj (assq inst *instruction-set*))
|
||||
@@ -36,9 +36,9 @@
|
||||
(write-bytevector bv))
|
||||
|
||||
(define (assemble inst-seq port)
|
||||
(define labels (find-labels inst-seq 1))
|
||||
(with-output-to-port port
|
||||
(lambda ()
|
||||
(define labels (find-labels inst-seq 1))
|
||||
(let loop ([seq inst-seq])
|
||||
(cond
|
||||
[(null? seq) '()]
|
||||
@@ -54,13 +54,5 @@
|
||||
(if (number? (cadr inst))
|
||||
(write-word (cadr inst))
|
||||
(write-word (assq-ref labels (cadr inst)))))
|
||||
(loop (cdr seq)))])))))
|
||||
|
||||
(define (assemble-file file out)
|
||||
(call-with-input-file file
|
||||
(lambda (in)
|
||||
(define (read-all next)
|
||||
(if (eof-object? next)
|
||||
'()
|
||||
(cons next (read-all (read in)))))
|
||||
(assemble (read-all (read in)) out))))
|
||||
(loop (cdr seq)))]))))
|
||||
labels)
|
||||
|
||||
Reference in New Issue
Block a user