git @ Cat's Eye Technologies SixtyPical / d3f730c
Move towards greater platform-agnosticism in these examples. Chris Pressey 2 years ago
17 changed file(s) with 49 addition(s) and 123 deletion(s). Raw diff Collapse all Expand all
33 Examples that are meant to fail and produce an error message
44 are in the `errorful/` subdirectory.
55
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,
916 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 ???
42
53 define print routine
64 trashes a, z, n
0 // Include `support/${PLATFORM}.60p` before this source
01 // Should print ENGGL
12
23 byte b
3
4 define chrout routine
5 inputs a
6 trashes a
7 @ 65490
84
95 define main routine
106 outputs b
0 // Include `support/${PLATFORM}.60p` before this source
01 // Should print ENGGL
12
23 word w1
34 word w2
4
5 define chrout routine
6 inputs a
7 trashes a
8 @ 65490
95
106 define main routine
117 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 ???
43
54 define main routine
65 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 ???
42
53 define main routine
64 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 ???
42
53 define bar routine trashes a, z, n {
64 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 ???
42
53 define main routine
64 trashes a, y, z, n, c
0 // Include `support/${PLATFORM}.60p` before this source
1 // Should print ???
2
03 byte foo
1
2 define chrout routine
3 inputs a
4 trashes a
5 @ 65490
64
75 define print routine
86 inputs foo
+0
-22
eg/rudiments/new-style-routine.60p less more
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
42
53 define main routine
64 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
-21
eg/rudiments/vector-inc.60p less more
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
-22
eg/rudiments/vector-main.60p less more
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 print
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 //
10 // Demonstrates vector tables.
2 // Prints "AABAB".
3 //
1 // Include `support/${PLATFORM}.60p` before this source
2 // Should print AABAB
43
54 vector routine
65 trashes a, z, n
98 vector (routine
109 trashes a, z, n)
1110 table[32] vectors
12
13 define chrout routine
14 inputs a
15 trashes a
16 @ 65490
1711
1812 define printa routine
1913 trashes a, z, n
0 // Include `support/${PLATFORM}.60p` before this source
1 // Should print ???
2
03 vector routine
14 trashes a, z, n
25 print
3
4 define chrout routine
5 inputs a
6 trashes a
7 @ 65490
86
97 define printa routine
108 trashes a, z, n