some obvious optimizations

This commit is contained in:
spannerisms
2021-02-14 01:44:05 -05:00
parent d9946e8f2a
commit 6be396543e
2 changed files with 76 additions and 58 deletions

View File

@@ -627,16 +627,15 @@ RTL
; caller is responsible for setting 8-bit mode and preserving X and Y
;--------------------------------------------------------------------------------
CountBits:
PHB : PHK : PLB
TAX ; Save a copy of value
LSR #4 ; Shift down hi nybble, Leave <3> in C
TAY ; And save <7:4> in Y
TXA ; Recover value
AND.b #$07 ; Put out <2:0> in X
TAX ; And save in X
LDA NybbleBitCounts, Y; Fetch count for Y
ADC.l NybbleBitCounts, X; Add count for X & C
PLB
TAX ; Save a copy of value
LSR #4 ; Shift down hi nybble, Leave <3> in C
TAY ; And save <7:4> in Y
TXA ; Recover value
AND.b #$07 ; Put out <2:0> in X
TAX ; And save in X
LDA.l NybbleBitCounts, X ; Fetch count for <2:0>
TYX ; get <7:4>
ADC.l NybbleBitCounts, X ; Add count for Y & C
RTL
; Look up table of bit counts in the values $00-$0F