#lang scheme/base
(require
"../rpn.ss"
"../scat.ss"
"../tools.ss"
"../target.ss"
"../asm.ss"
"../code.ss"
"tethered.ss"
"commands.ss"
"../port/ihex.ss"
scheme/control)
(provide
(all-defined-out))
(define *marks* '())
(define (mark) (push! *marks* (code-pointers)))
(define (empty [bits 5] [erase-from-block void])
(define (get x) (cadr (assq x (code-pointers))))
(unless (null? *marks*)
(code-pointers-set! (pop! *marks*)))
(let ((code (bit-ceil (get 'code) bits))
(data (get 'data)))
(code-pointers-set! `((code ,code)
(data ,data)))
(printf "FIXME: erasing: ")
(erase-from-block (>>> code bits))))
(define (commit [bin (code->binary)])
(unless (null? bin)
(upload-bytes bin)
(code-clear!)))
(define-syntax-rule (0cmd: command ...)
(begin
(snarf as-void (scat) (() (command ...)))
(prefix-parser-types (target) (0cmd command ...))))
(0cmd: commit code-print mark empty)
(prefix-parsers
(target)
((ul w) (empty mark load w commit)))