use uxncli debug format

This commit is contained in:
~d6 2025-01-20 01:33:58 -05:00
parent 7bd8afc386
commit 5f30e61907
1 changed files with 19 additions and 1 deletions

20
vm.scm
View File

@ -196,11 +196,29 @@
(define (_deo byte port)
(vector-set! dev port (u8 byte))
(cond
((= 14 port) (display wst) (display "\n") (display rst) (display "\n"))
((= 14 port) (debug))
((= 24 port) (write-char (integer->char byte) (current-output-port)))
((= 25 port) (write-char (integer->char byte) (current-error-port)))
(* '())))
(define (debug)
(debug-stack "WST" wst) (debug-stack "RST" rst))
(define (debug-stack label st)
(display label)
(debug-cells (cdr st) (u8 (- (car st) 8)) (car st) (current-output-port)))
(define (debug-cells cells i limit port)
(display (if (= i 0) "|" " ") port)
(if (= i limit) (display "<\n")
(begin
(emit-u8 (vector-ref cells i) port)
(debug-cells cells (u8 (+ i 1)) limit port))))
(define (emit-u8 n port)
(display (number->string (quotient n 16) 16) port)
(display (number->string (modulo n 16) 16) port))
; SFT base instruction implementation
(define (sft-impl k)
(let* ((n (_pop1))