From 1cad3802612bc8b293d75984277bc2d21e3b3905 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 | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/ip65/dottedquad_c.s b/ip65/dottedquad_c.s
index 5db827db..94d31e4d 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 tmp2
- beq :+
- ora #'0'
- sta dotted_quad,y ; write x00 if not 0
- iny
-: lda tmp1
+ lda tmp1
lsr
lsr
lsr
lsr
+ pha
+ lda tmp2
beq :+
ora #'0'
- sta dotted_quad,y ; write 0x0 if not 0
+ sta dotted_quad,y ; write x00
+ pla
+ iny
+ bne :++ ; always
+: pla
+ beq :++
+: ora #'0'
+ sta dotted_quad,y ; write 0x0
iny
: lda tmp1
and #$0F