git @ Cat's Eye Technologies SixtyPical / 5d01820
Small reorganization of example programs. Chris Pressey 2 years ago
9 changed file(s) with 51 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
00 This directory contains example sources which demonstrate
11 the rudiments of SixtyPical.
22
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.
45
56 They are not meant to be specific to any architecture, but
67 many do assume the existence of a routine at 65490 which
+0
-6
eg/rudiments/add-fail.60p less more
0 define add_four routine
1 inputs a
2 outputs a
3 {
4 add a, 4
5 }
+0
-20
eg/rudiments/bad-vector.60p less more
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
-9
eg/rudiments/range-error.60p less more
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 }
11 // Demonstrates vector tables.
22 // Prints "AABAB".
33 //
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.
412
513 vector routine
614 trashes a, z, n
4856 copy printb, vectors + x
4957
5058 ld x, 0
51 repeat {
59 for x up to 4 {
5260 copy vectors + x, print
5361 call print
54 inc x
55 cmp x, 5
56 } until z
62 }
5763 }