2015-10-17 11:28:39 +00:00
|
|
|
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
|
2015-10-17 12:50:21 +00:00
|
|
|
|
|
|
|
Call extern.
|
|
|
|
|
|
|
|
| routine chrout
|
|
|
|
| inputs a
|
|
|
|
| trashes a
|
|
|
|
| @ 65490
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| inputs a
|
2015-10-17 13:54:28 +00:00
|
|
|
| trashes a, z, n
|
2015-10-17 12:50:21 +00:00
|
|
|
| {
|
|
|
|
| ld a, 65
|
|
|
|
| call chrout
|
|
|
|
| }
|
2015-10-17 14:06:50 +00:00
|
|
|
= 00c0a94120d2ff60
|
2015-10-17 14:23:00 +00:00
|
|
|
|
|
|
|
Call defined routine.
|
|
|
|
|
|
|
|
| routine foo
|
|
|
|
| outputs a, x, y
|
|
|
|
| trashes z, n
|
|
|
|
| {
|
|
|
|
| ld a, 0
|
|
|
|
| ld x, 0
|
|
|
|
| ld y, 0
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, x, y, z, n
|
|
|
|
| {
|
|
|
|
| call foo
|
|
|
|
| }
|
|
|
|
= 00c02004c060a900a200a00060
|
2015-10-17 14:46:28 +00:00
|
|
|
|
|
|
|
Access a defined memory location.
|
|
|
|
|
|
|
|
| byte foo
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, y, z, n, foo
|
|
|
|
| {
|
|
|
|
| ld y, 0
|
|
|
|
| st y, foo
|
|
|
|
| ld a, foo
|
|
|
|
| }
|
|
|
|
= 00c0a0008c09c0ad09c060
|
2015-10-17 15:17:35 +00:00
|
|
|
|
2015-10-18 15:22:36 +00:00
|
|
|
| byte screen @ 1024
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, z, n, screen
|
|
|
|
| {
|
|
|
|
| ld a, 100
|
|
|
|
| st a, screen
|
|
|
|
| }
|
|
|
|
= 00c0a9648d000460
|
|
|
|
|
2015-10-17 15:17:35 +00:00
|
|
|
Some instructions.
|
|
|
|
|
|
|
|
| byte foo
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, x, y, z, n, c, v, foo
|
|
|
|
| {
|
|
|
|
| ld a, 0
|
|
|
|
| ld x, 0
|
|
|
|
| ld y, 0
|
|
|
|
| st a, foo
|
|
|
|
| st x, foo
|
|
|
|
| st y, foo
|
|
|
|
| st on, c
|
|
|
|
| st off, c
|
|
|
|
| add a, 1
|
|
|
|
| add a, foo
|
|
|
|
| sub a, 1
|
|
|
|
| sub a, foo
|
|
|
|
| inc foo
|
|
|
|
| inc x
|
|
|
|
| inc y
|
|
|
|
| dec foo
|
|
|
|
| dec x
|
|
|
|
| dec y
|
|
|
|
| and a, 255
|
|
|
|
| and a, foo
|
|
|
|
| or a, 255
|
|
|
|
| or a, foo
|
|
|
|
| xor a, 255
|
|
|
|
| xor a, foo
|
|
|
|
| cmp a, 1
|
|
|
|
| cmp a, foo
|
|
|
|
| cmp x, 1
|
|
|
|
| cmp x, foo
|
|
|
|
| cmp y, 1
|
|
|
|
| cmp y, foo
|
|
|
|
| shl a
|
|
|
|
| shr a
|
|
|
|
| }
|
|
|
|
= 00c0a900a200a0008d46c08e46c08c46c0381869016d46c0e901ed46c0ee46c0e8c8ce46c0ca8829ff2d46c009ff0d46c049ff4d46c0c901cd46c0e001ec46c0c001cc46c02a6a60
|
2015-10-17 15:34:02 +00:00
|
|
|
|
|
|
|
Compiling `if`.
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, x, y, z, n, c, v
|
|
|
|
| {
|
|
|
|
| ld a, 0
|
|
|
|
| if z {
|
|
|
|
| ld y, 1
|
|
|
|
| } else {
|
|
|
|
| ld y, 2
|
|
|
|
| }
|
|
|
|
| }
|
2015-10-17 17:11:23 +00:00
|
|
|
= 00c0a900d005a0014c0bc0a00260
|
|
|
|
|
2015-10-18 14:32:28 +00:00
|
|
|
Compiling `if not`.
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, x, y, z, n, c, v
|
|
|
|
| {
|
|
|
|
| ld a, 0
|
|
|
|
| if not z {
|
|
|
|
| ld y, 1
|
|
|
|
| } else {
|
|
|
|
| ld y, 2
|
|
|
|
| }
|
|
|
|
| }
|
|
|
|
= 00c0a900f005a0014c0bc0a00260
|
|
|
|
|
2015-10-17 17:11:23 +00:00
|
|
|
Compiling `if` without `else`.
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, x, y, z, n, c, v
|
|
|
|
| {
|
|
|
|
| ld a, 0
|
|
|
|
| if z {
|
|
|
|
| ld y, 1
|
|
|
|
| }
|
|
|
|
| }
|
2015-10-17 17:25:54 +00:00
|
|
|
= 00c0a900d002a00160
|
2015-10-18 12:55:40 +00:00
|
|
|
|
|
|
|
Compiling `repeat`.
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, y, z, n, c
|
|
|
|
| {
|
|
|
|
| ld y, 65
|
|
|
|
| repeat {
|
|
|
|
| ld a, y
|
|
|
|
| inc y
|
|
|
|
| cmp y, 91
|
|
|
|
| } until z
|
|
|
|
| }
|
|
|
|
= 00c0a04198c8c05bd0fa60
|
2015-10-18 14:32:28 +00:00
|
|
|
|
|
|
|
Compiling `repeat until not`.
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, y, z, n, c
|
|
|
|
| {
|
|
|
|
| ld y, 65
|
|
|
|
| repeat {
|
|
|
|
| ld a, y
|
|
|
|
| inc y
|
|
|
|
| cmp y, 91
|
|
|
|
| } until not z
|
|
|
|
| }
|
|
|
|
= 00c0a04198c8c05bf0fa60
|
|
|
|
|
|
|
|
Compiling `repeat forever`.
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| trashes a, y, z, n, c
|
|
|
|
| {
|
|
|
|
| ld y, 65
|
|
|
|
| repeat {
|
|
|
|
| inc y
|
|
|
|
| } forever
|
|
|
|
| }
|
|
|
|
= 00c0a041c84c02c060
|
2015-10-18 17:32:20 +00:00
|
|
|
|
|
|
|
Indexed access.
|
|
|
|
|
|
|
|
| byte one
|
|
|
|
| byte table many
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| outputs many
|
|
|
|
| trashes a, x, n, z
|
|
|
|
| {
|
|
|
|
| ld x, 0
|
|
|
|
| ld a, 0
|
|
|
|
| st a, many + x
|
|
|
|
| ld a, many + x
|
|
|
|
| }
|
|
|
|
= 00c0a200a9009d0dc0bd0dc060
|
2015-10-19 07:55:47 +00:00
|
|
|
|
|
|
|
Copy instruction..
|
|
|
|
|
|
|
|
| vector bar
|
|
|
|
| vector baz
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| inputs baz
|
|
|
|
| outputs bar
|
|
|
|
| trashes a, n, z
|
|
|
|
| {
|
|
|
|
| copy baz, bar
|
|
|
|
| }
|
|
|
|
= 00c0ad0fc08d0dc0ad10c08d0ec060
|
|
|
|
|
|
|
|
Copy instruction inside interrupts off block.
|
|
|
|
|
|
|
|
| vector bar
|
|
|
|
|
|
|
|
|
| routine foo
|
|
|
|
| inputs x
|
|
|
|
| outputs x
|
|
|
|
| trashes z, n
|
|
|
|
| {
|
|
|
|
| inc x
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| routine main
|
|
|
|
| inputs foo
|
|
|
|
| outputs bar
|
|
|
|
| trashes a, n, z
|
|
|
|
| {
|
|
|
|
| with interrupts off {
|
|
|
|
| copy foo, bar
|
|
|
|
| }
|
|
|
|
| }
|
|
|
|
= 00c078ad0fc08d11c0ad10c08d12c05860e860
|
2015-10-20 12:15:21 +00:00
|
|
|
|
|
|
|
Indirect call.
|
|
|
|
|
|
|
|
| vector foo outputs x trashes z, n
|
|
|
|
|
|
|
|
|
| routine bar outputs x trashes z, n {
|
|
|
|
| ld x, 200
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| routine main inputs bar outputs x, foo trashes a, z, n {
|
|
|
|
| copy bar, foo
|
|
|
|
| call foo
|
|
|
|
| }
|
2015-10-21 14:51:52 +00:00
|
|
|
= 00c0wewillfixthislater
|
|
|
|
|
|
|
|
goto.
|
|
|
|
|
|
|
|
| routine bar outputs x trashes z, n {
|
|
|
|
| ld x, 200
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| routine main outputs x trashes a, z, n {
|
|
|
|
| ld y, 200
|
|
|
|
| goto bar
|
|
|
|
| }
|
|
|
|
= 00c0a0c84c06c060a2c860
|