Optimized 95 bytes

This commit is contained in:
Michaelangel007 2017-07-05 22:27:57 -07:00
parent f87a71a06d
commit 1ce8c90bde
3 changed files with 12 additions and 14 deletions

View File

@ -1,6 +1,6 @@
# Print unsigned 16-bit
6502 assembly code to print an unsigned 16-bit in 96 bytes ($60).
6502 assembly code to print an unsigned 16-bit in 95 bytes ($5F).
Features:
@ -14,18 +14,18 @@ Copy/Paste into your favorite emulator.
```asm
0800:A9 12 A2 34 4C 07 08 8E
0808:65 08 8D 66 08 A9 00 8D
0810:61 08 8D 62 08 8D 63 08
0818:A2 10 F8 0E 65 08 2E 66
0820:08 A0 FD B9 64 07 79 64
0828:07 99 64 07 C8 D0 F4 CA
0830:D0 E9 D8 A0 03 B9 60 08
0808:64 08 8D 65 08 A9 00 8D
0810:60 08 8D 61 08 8D 62 08
0818:A2 10 F8 0E 64 08 2E 65
0820:08 A0 FD B9 63 07 79 63
0828:07 99 63 07 C8 D0 F4 CA
0830:D0 E9 D8 A0 03 B9 5F 08
0838:20 44 08 88 D0 F7 8A E0
0840:00 F0 11 60 48 20 7B F8
0848:20 4E 08 68 29 0F D0 04
0850:E0 00 F0 0C C9 0A 90 02
0858:69 06 69 B0 20 ED FD E8
0860:60 00 00 00 00 00 00
0850:E0 00 F0 EF C9 0A 90 02
0858:69 06 69 B0 E8 4C ED FD
0860:00 00 00 00 00 00
```

Binary file not shown.

View File

@ -71,7 +71,7 @@ HexA
_HexNib
BNE _HaveLeadingDigit ; If have leading zero and no output yet ...
CPX #0 ; ... then skip storing it
BEQ _HexAsciiDone
BEQ _PrintDone
_HaveLeadingDigit
CMP #$A ; n < 10 ?
@ -80,10 +80,8 @@ _HaveLeadingDigit
_Hex2Asc
ADC #'0' + $80 ; inverse=remove #$80
PutChar
JSR COUT
INX ; X = output string length
_HexAsciiDone
RTS
JMP COUT
_bcd ds 4 ; 6 chars for printing dec
_temp db 0,0