From 381b9d79121854fca428d43b00fbbdebdc0cca83 Mon Sep 17 00:00:00 2001 From: Michaelangel007 Date: Thu, 6 Jul 2017 15:54:01 -0700 Subject: [PATCH] Save off 2 bytes for zp version --- README.md | 20 ++++++++++---------- print_uint16_zp | Bin 76 -> 74 bytes print_uint16_zp.s | 6 ++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6a7ecf3..f255a0e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Features: * Highly optimized for space * No zero-page usage [version](print_uint16.s) 79 ($4F) bytes -* With zero-page usage [version](print_uint16_zp.s) 69 ($45) bytes +* With zero-page usage [version](print_uint16_zp.s) 67 ($43) bytes * With stack var usage [version](print_uint16_sp.s) 83 ($53) bytes * Only 2 ROM entry points used: PRHEXZ, SCRN2 * Includes 7 byte demo @@ -35,15 +35,15 @@ With-Zero-Page version: ```asm 0900:A9 12 A2 34 4C 07 09 86 -0908:FC 48 A0 00 84 FD 84 FE -0910:84 FF A0 10 F8 06 FC 68 -0918:2A 48 A2 FD B5 00 75 00 -0920:95 00 E8 D0 F7 88 D0 ED -0928:68 D8 A0 03 B9 FC 00 20 -0930:39 09 88 D0 F7 8A F0 0E -0938:60 48 20 7B F8 20 43 09 -0940:68 29 0F D0 01 CA E8 F0 -0948:EF 4C E5 FD +0908:FC A0 00 84 FD 84 FE 84 +0910:FF A0 10 F8 06 FC 2A 48 +0918:A2 FD B5 00 75 00 95 00 +0920:E8 D0 F7 68 88 D0 ED D8 +0928:A0 03 B9 FC 00 20 37 09 +0930:88 D0 F7 8A F0 0E 60 48 +0938:20 7B F8 20 41 09 68 29 +0940:0F D0 01 CA E8 F0 EF 4C +0948:E5 FD ``` With-Stack-Page version: diff --git a/print_uint16_zp b/print_uint16_zp index 256baccf772d388c16aa4788164f2e08139ce2f3..e4928cf4f153d92cee1d18af8b657e6761cdd6f8 100644 GIT binary patch literal 74 zcmV-Q0JZ5{3=MI{j~sf0F?mf(D!JF(Cyfu1G)SF gAU6q!(D#b)4q!+id-xzh31}$~&;iQm@b66J{bds+r~m)} literal 76 zcmV-S0JHz85~4Ir2MLD!NT2|O{e=F6|DX`~2K;C$NTU6<0CfPB0O-*7h|uk5*q{Ts i`~V<135d}5itr9#NFaOoAVUdgDG$&A%INU#Oy&KZgeF`7 diff --git a/print_uint16_zp.s b/print_uint16_zp.s index 2fba519..02b1502 100644 --- a/print_uint16_zp.s +++ b/print_uint16_zp.s @@ -25,7 +25,6 @@ _bcd = $fd ; NOTE: MUST be at $FD for ZP,X addressing in _DoubleDabble ; ====================================================================== PrintUint16 STX _temp - PHA ; Optimized: STA _temp+1 LDY #0 STY _bcd+0 @@ -39,9 +38,8 @@ _Dec2BCD ; https://en.wikipedia.org/wiki/Double_dabble ASL _temp+0 ; abcd efgh | ijkl mnop | ; ROL _temp+1 ; C=a bcde fghi | jklm nop0 | ; ; Bit 7654_3210 | 7654_3210 | - PLA ROL - PHA + PHA ; Optimized: STA _temp+1 LDX #$FD ; $00-$FD=-3 bcd[0] bcd[1] bcd[2] bcd[3] _DoubleDabble ; Y=FD Y=FE Y=FF Y=00 @@ -50,10 +48,10 @@ _DoubleDabble ; Y=FD Y=FE Y=FF Y=00 STA _bcd-$FD,X INX BNE _DoubleDabble + PLA ; keep stack DEY BNE _Dec2BCD - PLA ; keep stack CLD ; X=0 = output length DecWidth