Move towards greater platform-agnosticism in these examples.
Chris Pressey
3 years ago
3 | 3 | Examples that are meant to fail and produce an error message |
4 | 4 | are in the `errorful/` subdirectory. |
5 | 5 | |
6 | They are not meant to be specific to any architecture, but | |
7 | many do assume the existence of a routine at 65490 which | |
8 | outputs the value of the accumulator as an ASCII character, | |
6 | These files are intended to be architecture-agnostic. | |
7 | For the ones that do produce output, an appropriate source | |
8 | under `platform/`, should be included first, like | |
9 | ||
10 | sixtypical platform/c64.60p vector-table.60p | |
11 | ||
12 | so that system entry points such as `chrout` are defined. | |
13 | ||
14 | `chrout` is a routine with outputs the value of the accumulator | |
15 | as an ASCII character, disturbing none of the other registers, | |
9 | 16 | simply for the purposes of producing some observable output. |
10 | (This is an address of a KERNAL routine which does this | |
11 | on both the Commodore 64 and the Commodore VIC-20, so these | |
12 | sources should be usable on these architectures.) | |
17 | ||
18 | (There is a KERNAL routine which does this on both the | |
19 | Commodore 64 and the Commodore VIC-20. It should not be hard | |
20 | to find or write such a routine for most other architectures.) |
0 | define chrout routine | |
1 | inputs a | |
2 | trashes a | |
3 | @ 65490 | |
0 | // Include `support/${PLATFORM}.60p` before this source | |
1 | // Should print ??? | |
4 | 2 | |
5 | 3 | define print routine |
6 | 4 | trashes a, z, n |
0 | // Include `support/${PLATFORM}.60p` before this source | |
0 | 1 | // Should print ENGGL |
1 | 2 | |
2 | 3 | byte b |
3 | ||
4 | define chrout routine | |
5 | inputs a | |
6 | trashes a | |
7 | @ 65490 | |
8 | 4 | |
9 | 5 | define main routine |
10 | 6 | outputs b |
0 | // Include `support/${PLATFORM}.60p` before this source | |
0 | 1 | // Should print ENGGL |
1 | 2 | |
2 | 3 | word w1 |
3 | 4 | word w2 |
4 | ||
5 | define chrout routine | |
6 | inputs a | |
7 | trashes a | |
8 | @ 65490 | |
9 | 5 | |
10 | 6 | define main routine |
11 | 7 | outputs w1, w2 |
0 | define chrout routine | |
1 | inputs a | |
2 | trashes a | |
3 | @ 65490 | |
0 | // Demonstrates vector tables. | |
1 | // Include `support/${PLATFORM}.60p` before this source | |
2 | // Should print ??? | |
4 | 3 | |
5 | 4 | define main routine |
6 | 5 | trashes a, x, y, z, n, c, v |
0 | define chrout routine | |
1 | inputs a | |
2 | trashes a | |
3 | @ 65490 | |
0 | // Include `support/${PLATFORM}.60p` before this source | |
1 | // Should print ??? | |
4 | 2 | |
5 | 3 | define main routine |
6 | 4 | trashes a, x, y, z, n, c, v |
0 | define chrout routine | |
1 | inputs a | |
2 | trashes a | |
3 | @ 65490 | |
0 | // Include `support/${PLATFORM}.60p` before this source | |
1 | // Should print ??? | |
4 | 2 | |
5 | 3 | define bar routine trashes a, z, n { |
6 | 4 | ld a, 66 |
0 | define chrout routine | |
1 | inputs a | |
2 | trashes a | |
3 | @ 65490 | |
0 | // Include `support/${PLATFORM}.60p` before this source | |
1 | // Should print ??? | |
4 | 2 | |
5 | 3 | define main routine |
6 | 4 | trashes a, y, z, n, c |
0 | // Include `support/${PLATFORM}.60p` before this source | |
1 | // Should print ??? | |
2 | ||
0 | 3 | byte foo |
1 | ||
2 | define chrout routine | |
3 | inputs a | |
4 | trashes a | |
5 | @ 65490 | |
6 | 4 | |
7 | 5 | define print routine |
8 | 6 | inputs foo |
0 | // SixtyPical 0.11 introduced a new syntax for defining routines | |
1 | // (routine was made into a type, and you can now say: define name type.) | |
2 | ||
3 | typedef routine | |
4 | inputs x | |
5 | outputs x | |
6 | trashes z, n | |
7 | routine_type | |
8 | ||
9 | vector routine_type vec | |
10 | ||
11 | define foo routine_type | |
12 | { | |
13 | inc x | |
14 | } | |
15 | ||
16 | define main routine | |
17 | outputs vec | |
18 | trashes a, z, n | |
19 | { | |
20 | copy foo, vec | |
21 | } |
0 | define chrout routine | |
1 | inputs a | |
2 | trashes a | |
3 | @ 65490 | |
0 | // Include `support/${PLATFORM}.60p` before this source | |
1 | // Should print A | |
4 | 2 | |
5 | 3 | define main routine |
6 | 4 | inputs a |
0 | // Implementation of `chrout` for the Commodore 64 platform. | |
1 | ||
2 | define chrout routine | |
3 | inputs a | |
4 | trashes a | |
5 | @ 65490 |
0 | // Implementation of `chrout` for the Commodore VIC-20 platform. | |
1 | ||
2 | define chrout routine | |
3 | inputs a | |
4 | trashes a | |
5 | @ 65490 |
0 | // This will not compile on its own, because there is no `main`. | |
1 | // But this and `vector-main.60p` together will compile. | |
2 | ||
3 | define chrout routine | |
4 | inputs a | |
5 | trashes a | |
6 | @ 65490 | |
7 | ||
8 | define printa routine | |
9 | trashes a, z, n | |
10 | { | |
11 | ld a, 65 | |
12 | call chrout | |
13 | } | |
14 | ||
15 | define printb routine | |
16 | trashes a, z, n | |
17 | { | |
18 | ld a, 66 | |
19 | call chrout | |
20 | } |
0 | // This will not compile on its own, because `printa` and `printb` are not defined. | |
1 | // But `vector-inc.60p` and this together will compile. | |
2 | ||
3 | vector routine | |
4 | trashes a, z, n | |
5 | ||
6 | ||
7 | // routine printb | |
8 | // trashes a, z, n | |
9 | // { | |
10 | // ld a, 66 | |
11 | // call chrout | |
12 | // } | |
13 | ||
14 | define main routine | |
15 | trashes print, a, z, n | |
16 | { | |
17 | copy printa, print | |
18 | call print | |
19 | copy printb, print | |
20 | call print | |
21 | } |
0 | // | |
1 | 0 | // Demonstrates vector tables. |
2 | // Prints "AABAB". | |
3 | // | |
1 | // Include `support/${PLATFORM}.60p` before this source | |
2 | // Should print AABAB | |
4 | 3 | |
5 | 4 | vector routine |
6 | 5 | trashes a, z, n |
9 | 8 | vector (routine |
10 | 9 | trashes a, z, n) |
11 | 10 | table[32] vectors |
12 | ||
13 | define chrout routine | |
14 | inputs a | |
15 | trashes a | |
16 | @ 65490 | |
17 | 11 | |
18 | 12 | define printa routine |
19 | 13 | trashes a, z, n |