From 49bb5b578aa306c537328274ece7e368fd0421e3 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Tue, 25 Dec 2018 18:10:58 +0000 Subject: [PATCH] Extract utility routine to "support/stdlib.60p" source. --- eg/rudiments/example.60p | 29 +---------------------------- eg/rudiments/loadngo.sh | 2 +- eg/rudiments/support/stdlib.60p | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 29 deletions(-) create mode 100644 eg/rudiments/support/stdlib.60p diff --git a/eg/rudiments/example.60p b/eg/rudiments/example.60p index 8b27de6..a374c6e 100644 --- a/eg/rudiments/example.60p +++ b/eg/rudiments/example.60p @@ -1,35 +1,8 @@ -// Include `support/${PLATFORM}.60p` before this source +// Include `support/${PLATFORM}.60p` and `support/stdlib.60p` before this source // Should print 01 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, hexchars outputs lives diff --git a/eg/rudiments/loadngo.sh b/eg/rudiments/loadngo.sh index 18eab98..8fdb811 100755 --- a/eg/rudiments/loadngo.sh +++ b/eg/rudiments/loadngo.sh @@ -30,7 +30,7 @@ fi ### do it ### out=/tmp/a-out.prg -../../bin/sixtypical --traceback --output-format=$output_format support/$arch.60p $src --output $out || exit 1 +../../bin/sixtypical --traceback --output-format=$output_format support/$arch.60p support/stdlib.60p $src --output $out || exit 1 ls -la $out $emu $out rm -f $out diff --git a/eg/rudiments/support/stdlib.60p b/eg/rudiments/support/stdlib.60p new file mode 100644 index 0000000..548f030 --- /dev/null +++ b/eg/rudiments/support/stdlib.60p @@ -0,0 +1,26 @@ +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 + } + } +}