1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-01-22 18:34:53 +00:00

Add tests for compilation, BASIC header, load-n-go script.

This commit is contained in:
Chris Pressey 2015-10-17 12:28:39 +01:00
parent 5b429adfd9
commit d0e3dfbf84
6 changed files with 57 additions and 6 deletions

View File

@ -20,7 +20,7 @@ import traceback
from sixtypical.parser import Parser
from sixtypical.evaluator import eval_program
from sixtypical.analyzer import analyze_program
from sixtypical.emitter import Emitter
from sixtypical.emitter import Emitter, Byte, Word
from sixtypical.compiler import compile_program
@ -30,6 +30,9 @@ if __name__ == '__main__':
optparser.add_option("--analyze",
action="store_true", dest="analyze", default=False,
help="")
optparser.add_option("--basic-header",
action="store_true", dest="basic_header", default=False,
help="")
optparser.add_option("--compile",
action="store_true", dest="compile", default=False,
help="")
@ -59,10 +62,19 @@ if __name__ == '__main__':
else:
traceback.print_exception(e.__class__, e, None)
sys.exit(1)
print 'ok'
if options.compile:
emitter = Emitter(41952)
start_addr = 0xc000
header = []
if options.basic_header:
start_addr = 0x0801
header = [0x10, 0x08, 0xc9, 0x07, 0x9e, 0x32,
0x30, 0x36, 0x31, 0x00, 0x00, 0x00]
emitter = Emitter(start_addr)
# we are outputting a .PRG, so output the load address first
emitter.emit(Word(start_addr))
for byte in header:
emitter.emit(Byte(byte))
compile_program(program, emitter)
if options.debug:
print repr(emitter.accum)

View File

@ -1,7 +1,7 @@
routine add_four
inputs a
outputs a
trashes c
trashes c, z, n, v
{
st off, c
add a, 4

7
loadngo.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
SRC=$1
OUT=/tmp/a-out.prg
bin/sixtypical --analyze --compile --basic-header $SRC > $OUT || exit 1
x64 $OUT
rm -f $OUT

View File

@ -2,4 +2,5 @@
falderal --substring-error \
tests/SixtyPical\ Execution.md \
tests/SixtyPical\ Analysis.md
tests/SixtyPical\ Analysis.md \
tests/SixtyPical\ Compilation.md

View File

@ -7,7 +7,7 @@ static analysis rules.
[Falderal]: http://catseye.tc/node/Falderal
-> Functionality "Analyze SixtyPical program" is implemented by
-> shell command "bin/sixtypical --analyze %(test-body-file)"
-> shell command "bin/sixtypical --analyze %(test-body-file) && echo ok"
-> Tests for functionality "Analyze SixtyPical program"

View File

@ -0,0 +1,31 @@
Sixtypical Compilation
======================
This is a test suite, written in [Falderal][] format, for compiling
Sixtypical to 6502 machine code.
[Falderal]: http://catseye.tc/node/Falderal
-> Functionality "Compile Sixtypical program" is implemented by
-> shell command "bin/sixtypical --compile %(test-body-file) | fa-bin-to-hex"
-> Tests for functionality "Compile Sixtypical program"
Null program.
| routine main
| {
| }
= 00c060
Rudimentary program.
| routine main
| inputs a
| outputs a
| trashes c, z, n, v
| {
| st off, c
| add a, 4
| }
= 00c018690460