Skip to content

Commit

Permalink
Fixed dotted_quad().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oliverschmidt committed May 10, 2019
1 parent fe2063d commit 1cad380
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ip65/dottedquad_c.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1cad380

Please sign in to comment.