diff --git a/eg/rudiments/README.md b/eg/rudiments/README.md index 0567477..032249f 100644 --- a/eg/rudiments/README.md +++ b/eg/rudiments/README.md @@ -4,10 +4,18 @@ the rudiments of SixtyPical. Examples that are meant to fail and produce an error message are in the `errorful/` subdirectory. -They are not meant to be specific to any architecture, but -many do assume the existence of a routine at 65490 which -outputs the value of the accumulator as an ASCII character, +These files are intended to be architecture-agnostic. +For the ones that do produce output, an appropriate source +under `platform/`, should be included first, like + + sixtypical platform/c64.60p vector-table.60p + +so that system entry points such as `chrout` are defined. + +`chrout` is a routine with outputs the value of the accumulator +as an ASCII character, disturbing none of the other registers, simply for the purposes of producing some observable output. -(This is an address of a KERNAL routine which does this -on both the Commodore 64 and the Commodore VIC-20, so these -sources should be usable on these architectures.) + +(There is a KERNAL routine which does this on both the +Commodore 64 and the Commodore VIC-20. It should not be hard +to find or write such a routine for most other architectures.) diff --git a/eg/rudiments/call.60p b/eg/rudiments/call.60p index a7fc616..47eb9ed 100644 --- a/eg/rudiments/call.60p +++ b/eg/rudiments/call.60p @@ -1,7 +1,5 @@ -define chrout routine - inputs a - trashes a - @ 65490 +// Include `support/${PLATFORM}.60p` before this source +// Should print ??? define print routine trashes a, z, n diff --git a/eg/rudiments/cmp-byte.60p b/eg/rudiments/cmp-byte.60p index fdccd48..21e1f7b 100644 --- a/eg/rudiments/cmp-byte.60p +++ b/eg/rudiments/cmp-byte.60p @@ -1,12 +1,8 @@ +// Include `support/${PLATFORM}.60p` before this source // Should print ENGGL byte b -define chrout routine - inputs a - trashes a - @ 65490 - define main routine outputs b trashes a, x, y, z, n, c, v diff --git a/eg/rudiments/cmp-word.60p b/eg/rudiments/cmp-word.60p index ffbd46a..853c08e 100644 --- a/eg/rudiments/cmp-word.60p +++ b/eg/rudiments/cmp-word.60p @@ -1,13 +1,9 @@ +// Include `support/${PLATFORM}.60p` before this source // Should print ENGGL word w1 word w2 -define chrout routine - inputs a - trashes a - @ 65490 - define main routine outputs w1, w2 trashes a, x, y, z, n, c, v diff --git a/eg/rudiments/conditional.60p b/eg/rudiments/conditional.60p index 3cdb1fb..bf7c637 100644 --- a/eg/rudiments/conditional.60p +++ b/eg/rudiments/conditional.60p @@ -1,7 +1,6 @@ -define chrout routine - inputs a - trashes a - @ 65490 +// Demonstrates vector tables. +// Include `support/${PLATFORM}.60p` before this source +// Should print ??? define main routine trashes a, x, y, z, n, c, v diff --git a/eg/rudiments/conditional2.60p b/eg/rudiments/conditional2.60p index 6483cfd..6c37e4e 100644 --- a/eg/rudiments/conditional2.60p +++ b/eg/rudiments/conditional2.60p @@ -1,7 +1,5 @@ -define chrout routine - inputs a - trashes a - @ 65490 +// Include `support/${PLATFORM}.60p` before this source +// Should print ??? define main routine trashes a, x, y, z, n, c, v diff --git a/eg/rudiments/goto.60p b/eg/rudiments/goto.60p index 6aafcbb..faa0c4e 100644 --- a/eg/rudiments/goto.60p +++ b/eg/rudiments/goto.60p @@ -1,7 +1,5 @@ -define chrout routine - inputs a - trashes a - @ 65490 +// Include `support/${PLATFORM}.60p` before this source +// Should print ??? define bar routine trashes a, z, n { ld a, 66 diff --git a/eg/rudiments/loop.60p b/eg/rudiments/loop.60p index 2f3d95b..40598b1 100644 --- a/eg/rudiments/loop.60p +++ b/eg/rudiments/loop.60p @@ -1,7 +1,5 @@ -define chrout routine - inputs a - trashes a - @ 65490 +// Include `support/${PLATFORM}.60p` before this source +// Should print ??? define main routine trashes a, y, z, n, c diff --git a/eg/rudiments/memloc.60p b/eg/rudiments/memloc.60p index d6e49d1..2a255d5 100644 --- a/eg/rudiments/memloc.60p +++ b/eg/rudiments/memloc.60p @@ -1,9 +1,7 @@ -byte foo +// Include `support/${PLATFORM}.60p` before this source +// Should print ??? -define chrout routine - inputs a - trashes a - @ 65490 +byte foo define print routine inputs foo diff --git a/eg/rudiments/new-style-routine.60p b/eg/rudiments/new-style-routine.60p deleted file mode 100644 index 1b58c9b..0000000 --- a/eg/rudiments/new-style-routine.60p +++ /dev/null @@ -1,22 +0,0 @@ -// SixtyPical 0.11 introduced a new syntax for defining routines -// (routine was made into a type, and you can now say: define name type.) - -typedef routine - inputs x - outputs x - trashes z, n - routine_type - -vector routine_type vec - -define foo routine_type -{ - inc x -} - -define main routine - outputs vec - trashes a, z, n -{ - copy foo, vec -} diff --git a/eg/rudiments/print.60p b/eg/rudiments/print.60p index d060ebc..7589930 100644 --- a/eg/rudiments/print.60p +++ b/eg/rudiments/print.60p @@ -1,7 +1,5 @@ -define chrout routine - inputs a - trashes a - @ 65490 +// Include `support/${PLATFORM}.60p` before this source +// Should print A define main routine inputs a diff --git a/eg/rudiments/support/c64.60p b/eg/rudiments/support/c64.60p new file mode 100644 index 0000000..568d8b4 --- /dev/null +++ b/eg/rudiments/support/c64.60p @@ -0,0 +1,6 @@ +// Implementation of `chrout` for the Commodore 64 platform. + +define chrout routine + inputs a + trashes a + @ 65490 diff --git a/eg/rudiments/support/vic20.60p b/eg/rudiments/support/vic20.60p new file mode 100644 index 0000000..15476b6 --- /dev/null +++ b/eg/rudiments/support/vic20.60p @@ -0,0 +1,6 @@ +// Implementation of `chrout` for the Commodore VIC-20 platform. + +define chrout routine + inputs a + trashes a + @ 65490 diff --git a/eg/rudiments/vector-inc.60p b/eg/rudiments/vector-inc.60p deleted file mode 100644 index 1e2bd8e..0000000 --- a/eg/rudiments/vector-inc.60p +++ /dev/null @@ -1,21 +0,0 @@ -// This will not compile on its own, because there is no `main`. -// But this and `vector-main.60p` together will compile. - -define chrout routine - inputs a - trashes a - @ 65490 - -define printa routine - trashes a, z, n -{ - ld a, 65 - call chrout -} - -define printb routine - trashes a, z, n -{ - ld a, 66 - call chrout -} diff --git a/eg/rudiments/vector-main.60p b/eg/rudiments/vector-main.60p deleted file mode 100644 index f8df898..0000000 --- a/eg/rudiments/vector-main.60p +++ /dev/null @@ -1,22 +0,0 @@ -// This will not compile on its own, because `printa` and `printb` are not defined. -// But `vector-inc.60p` and this together will compile. - -vector routine - trashes a, z, n - print - -// routine printb -// trashes a, z, n -// { -// ld a, 66 -// call chrout -// } - -define main routine - trashes print, a, z, n -{ - copy printa, print - call print - copy printb, print - call print -} diff --git a/eg/rudiments/vector-table.60p b/eg/rudiments/vector-table.60p index 6d6e98a..0bead91 100644 --- a/eg/rudiments/vector-table.60p +++ b/eg/rudiments/vector-table.60p @@ -1,7 +1,6 @@ -// // Demonstrates vector tables. -// Prints "AABAB". -// +// Include `support/${PLATFORM}.60p` before this source +// Should print AABAB vector routine trashes a, z, n @@ -11,11 +10,6 @@ vector (routine trashes a, z, n) table[32] vectors -define chrout routine - inputs a - trashes a - @ 65490 - define printa routine trashes a, z, n { diff --git a/eg/rudiments/vector.60p b/eg/rudiments/vector.60p index 7783165..9008745 100644 --- a/eg/rudiments/vector.60p +++ b/eg/rudiments/vector.60p @@ -1,12 +1,10 @@ +// Include `support/${PLATFORM}.60p` before this source +// Should print ??? + vector routine trashes a, z, n print -define chrout routine - inputs a - trashes a - @ 65490 - define printa routine trashes a, z, n {