From 2594daeb6bafe7983901502efabc839bb9edce18 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Fri, 10 May 2019 11:55:32 +0200 Subject: [PATCH] Fixed dotted_quad(). Omitting the middle digit because it is '0' must only be done if the high digit was omitted too (because it was '0'). If the high digit is '1' or '2' (and therefore not omitted) then the middle digit must never be omitted. --- ip65/dottedquad_c.s | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ip65/dottedquad_c.s b/ip65/dottedquad_c.s index 5db827d..94d31e4 100644 --- a/ip65/dottedquad_c.s +++ b/ip65/dottedquad_c.s @@ -35,7 +35,8 @@ _dotted_quad: rts convert_byte: -; hex to bcd routine taken from Andrew Jacob's code at http://www.6502.org/source/integers/hex2dec-more.htm +; hex to bcd routine taken from Andrew Jacob's code at +; http://www.6502.org/source/integers/hex2dec-more.htm sed ; switch to decimal mode lda #$00 ; ensure the result is clear sta tmp1 ; BCD low @@ -53,19 +54,23 @@ convert_byte: bne :- cld ; back to binary + lda tmp1 + lsr + lsr + lsr + lsr + pha lda tmp2 beq :+ ora #'0' - sta dotted_quad,y ; write x00 if not 0 + sta dotted_quad,y ; write x00 + pla iny -: lda tmp1 - lsr - lsr - lsr - lsr - beq :+ - ora #'0' - sta dotted_quad,y ; write 0x0 if not 0 + bne :++ ; always +: pla + beq :++ +: ora #'0' + sta dotted_quad,y ; write 0x0 iny : lda tmp1 and #$0F