From 0ec8970c766cb6761da1ab2e7c919e780d3133a1 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Wed, 12 Dec 2018 09:27:25 +0000 Subject: [PATCH] Expand example with code that will likely become library support. --- eg/rudiments/example.60p | 47 ++++++++++++++++++++++++++++++++-------- eg/rudiments/if.60p | 12 ---------- 2 files changed, 38 insertions(+), 21 deletions(-) delete mode 100644 eg/rudiments/if.60p diff --git a/eg/rudiments/example.60p b/eg/rudiments/example.60p index c4475da..9eefa8e 100644 --- a/eg/rudiments/example.60p +++ b/eg/rudiments/example.60p @@ -1,14 +1,43 @@ byte lives +byte table[16] hexchars : "0123456789ABCDEF" + +define prbyte routine + inputs a, hexchars + trashes a, z, n, c, v +{ + save x { + save a { + st off, c + shr a + shr a + shr a + shr a + and a, 15 + ld x, a + ld a, hexchars + x + call chrout + } + save a { + and a, 15 + ld x, a + ld a, hexchars + x + call chrout + } + } +} + define main routine - inputs lives + inputs lives, hexchars outputs lives trashes a, x, z, n, c, v - { - ld a, 0 - st a, lives - ld x, lives - st off, c - add x, 1 - st x, lives - } +{ + ld a, 0 + st a, lives + ld x, lives + st off, c + inc x + st x, lives + ld a, lives + call prbyte +} diff --git a/eg/rudiments/if.60p b/eg/rudiments/if.60p deleted file mode 100644 index 9b0b968..0000000 --- a/eg/rudiments/if.60p +++ /dev/null @@ -1,12 +0,0 @@ -define main routine - inputs a - outputs a - trashes z, n, c -{ - cmp a, 42 - if z { - ld a, 7 - } else { - ld a, 23 - } -}