File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838 ; IMPROVE ME: hard-coded heap size
3939 (malloc _int64 20000 'raw ))
4040
41+
42+ ;; Integer -> String
43+ (define (number->binary n)
44+ (format "#b~a "
45+ (~r n #:base 2 #:min-width 64 #:pad-string "0 " )))
46+
47+ ;; Integer -> String
48+ (define (number->octal n)
49+ (format "#o~a "
50+ (~r n #:base 8 #:min-width 22 #:pad-string "0 " )))
51+
52+ (define (number->hex n)
53+ (format "#x~a "
54+ (~r n #:base 16 #:min-width 16 #:pad-string "0 " )))
55+
56+ (define (show-state . regs)
57+ (for-each (lambda (v)
58+ (printf "reg: ~a\n " (number->hex v)))
59+ regs))
60+
4161;; Asm String -> (cons Value String)
4262;; Like asm-interp, but uses given string for input and returns
4363;; result with string output
7595 (set-ffi-obj! "error_handler " libt.so _pointer
7696 (function-ptr (λ () (raise 'err )) (_fun _-> _void))))
7797
98+ (when (ffi-obj-ref "place " libt.so (thunk #f ))
99+ (set-ffi-obj! "place " libt.so _pointer
100+ (function-ptr (λ (n)
101+ (apply show-state
102+ (build-list 16 (lambda (i) (ptr-ref n _int64 (add1 i))))))
103+ (_fun _pointer _-> _void))))
78104
79105 (define has-heap? #f )
80106
You can’t perform that action at this time.
0 commit comments