fizzbuzz.s: Add a dummy high length byte.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 14 Nov 2021 15:03:23 +0000 (15:03 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 14 Nov 2021 15:03:23 +0000 (15:03 +0000)
The length is still only one byte, but the extra zero means we can load
the BC in a single instruction rather than having to prat about with
setting up the two halves separately -- and loading C via A because of
instruction-set limitations.

fizzbuzz.s

index 8521554..00504d4 100644 (file)
@@ -57,10 +57,8 @@ nobuzz:      ld      a, e
        jr      nz, prnl
 
        ;; OK, so just print the value.
-       ld      a, (len)
-       ld      b, 0
-       ld      c, a
        ld      hl, buf - 1
+       ld      bc, (len)
        add     hl, bc
        ld      b, c
 
@@ -146,5 +144,5 @@ print:
 
        ;; Initial state.  The buffer notionally continues for another 254
        ;; bytes, but there's no point in including them in the image.
-len:   db      1
+len:   db      1, 0
 buf:   db      1