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
|
COUT = $FDED
|
||||||
|
SCRN2 = $F879
|
||||||
|
|
||||||
ORG $800
|
ORG $800
|
||||||
|
|
||||||
@ -12,11 +13,10 @@ COUT = $FDED
|
|||||||
; Also see: Applesoft LINPRT @ ED24
|
; Also see: Applesoft LINPRT @ ED24
|
||||||
; ======================================================================
|
; ======================================================================
|
||||||
PrintUint16
|
PrintUint16
|
||||||
STX _temp+0
|
STX _temp+0
|
||||||
STA _temp+1
|
STA _temp+1
|
||||||
|
|
||||||
LDA #0
|
LDA #0
|
||||||
STA _len ; output buffer len = num digits to print
|
|
||||||
STA _bcd+0
|
STA _bcd+0
|
||||||
STA _bcd+1
|
STA _bcd+1
|
||||||
STA _bcd+2
|
STA _bcd+2
|
||||||
@ -38,7 +38,7 @@ _DoubleDabble ; Y=FD Y=FE Y=FF Y=00
|
|||||||
|
|
||||||
DEX
|
DEX
|
||||||
BNE _Dec2BCD
|
BNE _Dec2BCD
|
||||||
CLD
|
CLD ; X=0 = output length
|
||||||
|
|
||||||
DecWidth
|
DecWidth
|
||||||
LDY #3 ; intentional buffer overflow - 8 digit output for special case of $0000
|
LDY #3 ; intentional buffer overflow - 8 digit output for special case of $0000
|
||||||
@ -48,6 +48,8 @@ BCD2Chars
|
|||||||
DEY
|
DEY
|
||||||
BPL BCD2Chars
|
BPL BCD2Chars
|
||||||
|
|
||||||
|
STX _len ; output buffer len = num digits to print
|
||||||
|
|
||||||
SkipLeadZero
|
SkipLeadZero
|
||||||
INY
|
INY
|
||||||
CPY _len
|
CPY _len
|
||||||
@ -58,7 +60,7 @@ SkipLeadZero
|
|||||||
|
|
||||||
OutDigits
|
OutDigits
|
||||||
LDA _output,Y ; always print digit in "ones" place
|
LDA _output,Y ; always print digit in "ones" place
|
||||||
JSR COUT
|
JSR COUT
|
||||||
INY
|
INY
|
||||||
CPY _len
|
CPY _len
|
||||||
BCC OutDigits
|
BCC OutDigits
|
||||||
@ -70,27 +72,24 @@ _PrintDone
|
|||||||
; @return: A will be bottom nibble in ASCII
|
; @return: A will be bottom nibble in ASCII
|
||||||
HexA
|
HexA
|
||||||
PHA
|
PHA
|
||||||
LSR
|
JSR SCRN2+2 ; LSR x4 == 0>> 4
|
||||||
LSR
|
|
||||||
LSR
|
|
||||||
LSR
|
|
||||||
JSR _HexNib
|
JSR _HexNib
|
||||||
PLA
|
PLA
|
||||||
|
AND #$F
|
||||||
_HexNib
|
_HexNib
|
||||||
AND #$F ; Can NOT't Use ROM Entry Point SCRN2+2 as the Laser 128 leaves off AND #$F !!
|
|
||||||
CMP #$A ; n < 10 ?
|
CMP #$A ; n < 10 ?
|
||||||
BCC _Hex2Asc
|
BCC _Hex2Asc
|
||||||
ADC #6 ; n += 6 $A -> +6 + (C=1) = $11
|
ADC #6 ; n += 6 $A -> +6 + (C=1) = $11
|
||||||
_Hex2Asc
|
_Hex2Asc
|
||||||
ADC #'0' + $80 ; inverse=remove #$80
|
ADC #'0' + $80 ; inverse=remove #$80
|
||||||
PutChar
|
PutChar
|
||||||
LDX #0 ; NOTE: length = PutChar+1
|
|
||||||
STA _output,X
|
STA _output,X
|
||||||
INC _len
|
INX ; X = output string length
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
|
||||||
_bcd ds 4 ; 6 chars for printing dec
|
_bcd ds 4 ; 6 chars for printing dec
|
||||||
_len = PutChar+1
|
_len = _bcd ; alias
|
||||||
_output ds 6 ; BCD -> 6 chars
|
_output ds 6 ; BCD -> 6 chars
|
||||||
_temp db 0,0
|
_temp db 0,0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user