Begin debugger

This commit is contained in:
2025-06-09 09:02:20 -05:00
parent 679b53d76e
commit a36eea12d0
3 changed files with 31 additions and 203 deletions

View File

@@ -5,7 +5,7 @@
#:use-module (rnrs io ports)
#:use-module ((scheme base)
#:select (write-u8 write-bytevector))
#:export (assemble))
#:export (assemble assemble-file))
(define (lookup-instruction inst)
(define inst-obj (assq inst *instruction-set*))
@@ -55,3 +55,12 @@
(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))))