mirror of
https://github.com/Michaelangel007/apple2_print_uint16.git
synced 2024-12-28 13:30:55 +00:00
Merge Peter's optimization 119 bytes
This commit is contained in:
parent
242811e99a
commit
7baae0bc3f
BIN
print_uint16
BIN
print_uint16
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
COUT = $FDED
|
||||
SCRN2 = $F879
|
||||
|
||||
ORG $800
|
||||
|
||||
@ -16,7 +17,6 @@ PrintUint16
|
||||
STA _temp+1
|
||||
|
||||
LDA #0
|
||||
STA _len ; output buffer len = num digits to print
|
||||
STA _bcd+0
|
||||
STA _bcd+1
|
||||
STA _bcd+2
|
||||
@ -38,7 +38,7 @@ _DoubleDabble ; Y=FD Y=FE Y=FF Y=00
|
||||
|
||||
DEX
|
||||
BNE _Dec2BCD
|
||||
CLD
|
||||
CLD ; X=0 = output length
|
||||
|
||||
DecWidth
|
||||
LDY #3 ; intentional buffer overflow - 8 digit output for special case of $0000
|
||||
@ -48,6 +48,8 @@ BCD2Chars
|
||||
DEY
|
||||
BPL BCD2Chars
|
||||
|
||||
STX _len ; output buffer len = num digits to print
|
||||
|
||||
SkipLeadZero
|
||||
INY
|
||||
CPY _len
|
||||
@ -70,27 +72,24 @@ _PrintDone
|
||||
; @return: A will be bottom nibble in ASCII
|
||||
HexA
|
||||
PHA
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
JSR SCRN2+2 ; LSR x4 == 0>> 4
|
||||
JSR _HexNib
|
||||
PLA
|
||||
AND #$F
|
||||
_HexNib
|
||||
AND #$F ; Can NOT't Use ROM Entry Point SCRN2+2 as the Laser 128 leaves off AND #$F !!
|
||||
CMP #$A ; n < 10 ?
|
||||
BCC _Hex2Asc
|
||||
ADC #6 ; n += 6 $A -> +6 + (C=1) = $11
|
||||
_Hex2Asc
|
||||
ADC #'0' + $80 ; inverse=remove #$80
|
||||
PutChar
|
||||
LDX #0 ; NOTE: length = PutChar+1
|
||||
STA _output,X
|
||||
INC _len
|
||||
INX ; X = output string length
|
||||
RTS
|
||||
|
||||
|
||||
_bcd ds 4 ; 6 chars for printing dec
|
||||
_len = PutChar+1
|
||||
_len = _bcd ; alias
|
||||
_output ds 6 ; BCD -> 6 chars
|
||||
_temp db 0,0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user