git @ Cat's Eye Technologies SixtyPical / d0e3dfb
Add tests for compilation, BASIC header, load-n-go script. Chris Pressey 9 years ago
6 changed file(s) with 57 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
1919 from sixtypical.parser import Parser
2020 from sixtypical.evaluator import eval_program
2121 from sixtypical.analyzer import analyze_program
22 from sixtypical.emitter import Emitter
22 from sixtypical.emitter import Emitter, Byte, Word
2323 from sixtypical.compiler import compile_program
2424
2525
2828
2929 optparser.add_option("--analyze",
3030 action="store_true", dest="analyze", default=False,
31 help="")
32 optparser.add_option("--basic-header",
33 action="store_true", dest="basic_header", default=False,
3134 help="")
3235 optparser.add_option("--compile",
3336 action="store_true", dest="compile", default=False,
5861 else:
5962 traceback.print_exception(e.__class__, e, None)
6063 sys.exit(1)
61 print 'ok'
6264
6365 if options.compile:
64 emitter = Emitter(41952)
66 start_addr = 0xc000
67 header = []
68 if options.basic_header:
69 start_addr = 0x0801
70 header = [0x10, 0x08, 0xc9, 0x07, 0x9e, 0x32,
71 0x30, 0x36, 0x31, 0x00, 0x00, 0x00]
72 emitter = Emitter(start_addr)
73 # we are outputting a .PRG, so output the load address first
74 emitter.emit(Word(start_addr))
75 for byte in header:
76 emitter.emit(Byte(byte))
6577 compile_program(program, emitter)
6678 if options.debug:
6779 print repr(emitter.accum)
00 routine add_four
11 inputs a
22 outputs a
3 trashes c
3 trashes c, z, n, v
44 {
55 st off, c
66 add a, 4
0 #!/bin/sh
1
2 SRC=$1
3 OUT=/tmp/a-out.prg
4 bin/sixtypical --analyze --compile --basic-header $SRC > $OUT || exit 1
5 x64 $OUT
6 rm -f $OUT
11
22 falderal --substring-error \
33 tests/SixtyPical\ Execution.md \
4 tests/SixtyPical\ Analysis.md
4 tests/SixtyPical\ Analysis.md \
5 tests/SixtyPical\ Compilation.md
66 [Falderal]: http://catseye.tc/node/Falderal
77
88 -> Functionality "Analyze SixtyPical program" is implemented by
9 -> shell command "bin/sixtypical --analyze %(test-body-file)"
9 -> shell command "bin/sixtypical --analyze %(test-body-file) && echo ok"
1010
1111 -> Tests for functionality "Analyze SixtyPical program"
1212
0 Sixtypical Compilation
1 ======================
2
3 This is a test suite, written in [Falderal][] format, for compiling
4 Sixtypical to 6502 machine code.
5
6 [Falderal]: http://catseye.tc/node/Falderal
7
8 -> Functionality "Compile Sixtypical program" is implemented by
9 -> shell command "bin/sixtypical --compile %(test-body-file) | fa-bin-to-hex"
10
11 -> Tests for functionality "Compile Sixtypical program"
12
13 Null program.
14
15 | routine main
16 | {
17 | }
18 = 00c060
19
20 Rudimentary program.
21
22 | routine main
23 | inputs a
24 | outputs a
25 | trashes c, z, n, v
26 | {
27 | st off, c
28 | add a, 4
29 | }
30 = 00c018690460