Small reorganization of example programs.
Chris Pressey
3 years ago
0 | 0 |
This directory contains example sources which demonstrate
|
1 | 1 |
the rudiments of SixtyPical.
|
2 | 2 |
|
3 | |
Some are meant to fail and produce an error message.
|
|
3 |
Examples that are meant to fail and produce an error message
|
|
4 |
are in the `errorful/` subdirectory.
|
4 | 5 |
|
5 | 6 |
They are not meant to be specific to any architecture, but
|
6 | 7 |
many do assume the existence of a routine at 65490 which
|
0 | |
define add_four routine
|
1 | |
inputs a
|
2 | |
outputs a
|
3 | |
{
|
4 | |
add a, 4
|
5 | |
}
|
0 | |
vector vec
|
1 | |
inputs y
|
2 | |
outputs y
|
3 | |
trashes z, n
|
4 | |
|
5 | |
routine foo
|
6 | |
inputs x
|
7 | |
outputs x
|
8 | |
trashes z, n
|
9 | |
{
|
10 | |
inc x
|
11 | |
}
|
12 | |
|
13 | |
routine main
|
14 | |
inputs foo
|
15 | |
outputs vec
|
16 | |
trashes a, z, n
|
17 | |
{
|
18 | |
copy foo, vec
|
19 | |
}
|
|
0 |
This directory contains example SixtyPical sources which
|
|
1 |
are intentionally invalid (for demonstration purposes)
|
|
2 |
and are expected to elicit an error message from a
|
|
3 |
SixtyPical implementation.
|
|
0 |
define add_four routine
|
|
1 |
inputs a
|
|
2 |
outputs a
|
|
3 |
{
|
|
4 |
add a, 4
|
|
5 |
}
|
|
0 |
byte table[8] message : "WHAT?"
|
|
1 |
|
|
2 |
define main routine
|
|
3 |
inputs message
|
|
4 |
outputs x, a, z, n
|
|
5 |
{
|
|
6 |
ld x, 9
|
|
7 |
ld a, message + x
|
|
8 |
}
|
|
0 |
vector vec
|
|
1 |
inputs y
|
|
2 |
outputs y
|
|
3 |
trashes z, n
|
|
4 |
|
|
5 |
routine foo
|
|
6 |
inputs x
|
|
7 |
outputs x
|
|
8 |
trashes z, n
|
|
9 |
{
|
|
10 |
inc x
|
|
11 |
}
|
|
12 |
|
|
13 |
routine main
|
|
14 |
inputs foo
|
|
15 |
outputs vec
|
|
16 |
trashes a, z, n
|
|
17 |
{
|
|
18 |
copy foo, vec
|
|
19 |
}
|
0 | |
byte table[8] message : "WHAT?"
|
1 | |
|
2 | |
define main routine
|
3 | |
inputs message
|
4 | |
outputs x, a, z, n
|
5 | |
{
|
6 | |
ld x, 9
|
7 | |
ld a, message + x
|
8 | |
}
|
1 | 1 |
// Demonstrates vector tables.
|
2 | 2 |
// Prints "AABAB".
|
3 | 3 |
//
|
|
4 |
|
|
5 |
// TODO: this doesn't pass the analyzer currently, which suggests a bug.
|
|
6 |
//
|
|
7 |
// RangeExceededError: Possible range of x:byte (0, 255) exceeds
|
|
8 |
// acceptable range of vectors:vector table[32] (0, 31) (in main, line 57)
|
|
9 |
//
|
|
10 |
// (despite various attempts to work around by calling a setup routine, etc.)
|
|
11 |
// It should really be able to figure out that the range of x is 0..4 there.
|
4 | 12 |
|
5 | 13 |
vector routine
|
6 | 14 |
trashes a, z, n
|
|
48 | 56 |
copy printb, vectors + x
|
49 | 57 |
|
50 | 58 |
ld x, 0
|
51 | |
repeat {
|
|
59 |
for x up to 4 {
|
52 | 60 |
copy vectors + x, print
|
53 | 61 |
call print
|
54 | |
inc x
|
55 | |
cmp x, 5
|
56 | |
} until z
|
|
62 |
}
|
57 | 63 |
}
|