3 (include "pic18-sim.scm")
4 (include "utilities.scm")
6 (include "operators.scm")
10 (include "optimizations.scm")
11 (include "code-generation.scm")
14 ;------------------------------------------------------------------------------
16 ;; temporary solution, to support more than int
17 (set! ##six-types ;; TODO unsigned types ?
22 (int24 . #f) ;; TODO useful ? is currently used for 8x16 multiplications
30 ;; TODO typedef should add to this list
32 (define (read-source filename)
33 (shell-command (string-append "cpp -P " filename " > " filename ".tmp"))
34 ;; (##read-all-as-a-begin-expr-from-path ;; TODO use vectorized notation to have info on errors (where in the source)
35 ;; (string-append filename ".tmp")
36 ;; (readtable-start-syntax-set (current-readtable) 'six)
40 (string-append filename ".tmp")
42 (input-port-readtable-set!
44 (readtable-start-syntax-set
45 (input-port-readtable (current-input-port))
50 (define (main filename)
52 (output-port-readtable-set!
54 (readtable-sharing-allowed?-set
55 (output-port-readtable (current-output-port))
58 (let ((source (read-source filename)))
59 '(pretty-print source)
60 (let* ((ast (parse source)))
62 (let ((cfg (generate-cfg ast)))
65 (remove-branch-cascades-and-dead-code cfg)
66 (remove-converging-branches cfg)
67 (remove-dead-instructions cfg)
71 (let ((code (code-gen filename cfg)))
73 '(display "------------------ GENERATED CODE\n")
74 (asm-display-listing (current-output-port))
75 (asm-write-hex-file (string-append filename ".hex"))
77 '(display "------------------ EXECUTION USING SIMULATOR\n")
78 (execute-hex-file (string-append filename ".hex"))