-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli.rkt
executable file
·37 lines (30 loc) · 927 Bytes
/
cli.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env racket
#lang racket/base
(require
racket/cmdline
racket/function
racket/string
virtual-mpu
command-tree)
(define (assemble-to-binary mpu assembly)
(display (assemble assembly)))
(define (assemble-to-hex mpu assembly)
(displayln
(string-join
(map (curry format-hex)
(bytes->list (assemble assembly))))))
(define (assemble-to-s-record mpu assembly [header #f])
(bytes->s-record (assemble assembly)
#:header header))
(define (emulate-machine machine kernel)
(emulate machine kernel))
(define (test-mpu mpu)
(local-require rackunit/text-ui)
(run-tests (dynamic-require (format "mpus/~a.test" mpu) 'suite)))
(command-tree
`([assemble (to-binary ,assemble-to-binary)
(to-hex ,assemble-to-hex)
(to-s-record ,assemble-to-s-record)]
[emulate ,emulate-machine]
[test ,test-mpu])
(current-command-line-arguments))