Difference between revisions of "Z80 Routines:Optimized:reverseA"
From WikiTI
(New page: reverseA reverseA reverseA This is a faster/smaller (and also obfuscated) replacement for t...) |
Calc84maniac (Talk | contribs) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category:Z80 Routines:Optimized| | + | [[Category:Z80 Routines:Optimized|ReverseA]] |
− | [[Category:Z80 Routines:Graphic| | + | [[Category:Z80 Routines:Graphic|ReverseA]] |
− | [[Category:Z80 Routines| | + | [[Category:Z80 Routines|ReverseA]] |
− | + | ||
This is a faster/smaller (and also obfuscated) replacement for the normal reverse a. | This is a faster/smaller (and also obfuscated) replacement for the normal reverse a. | ||
Line 33: | Line 32: | ||
;output: Reversed byte in A | ;output: Reversed byte in A | ||
;destroys B | ;destroys B | ||
− | ; | + | ;17 bytes and 66 clock cycles |
;author: calcmaniac84 | ;author: calcmaniac84 | ||
− | + | ReverseA: | |
− | ld b,a | + | ld b,a ;b=ABCDEFGH |
− | rrca | + | rrca ;a=HABCDEFG |
− | rrca | + | rrca ;a=GHABCDEF |
− | xor b | + | xor b \ and %10101010 \ xor b ;a=GBADCFEH |
− | + | ld b,a ;b=GBADCFEH | |
− | + | rrca ;a=HGBADCFE | |
− | ld b,a | + | rrca ;a=EHGBADCF |
− | rrca | + | rrca ;a=FEHGBADC |
− | rrca | + | rrca ;a=CFEHGBAD |
− | rrca | + | xor b \ and %01100110 \ xor b ;a=GFEDCBAH |
− | rrca | + | rrca ;a=HGFEDCBA</nowiki> |
− | xor b | + | |
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 11:59, 31 August 2011
This is a faster/smaller (and also obfuscated) replacement for the normal reverse a.
Typical routine:
;input: b ;output: a ;25 bytes, 96 clock cycles typicalreversea: rr b rla rr b rla rr b rla rr b rla rr b rla rr b rla rr b rla rr b rla ret
Better routine:
;- Reverse a ;input: byte in A ;output: Reversed byte in A ;destroys B ;17 bytes and 66 clock cycles ;author: calcmaniac84 ReverseA: ld b,a ;b=ABCDEFGH rrca ;a=HABCDEFG rrca ;a=GHABCDEF xor b \ and %10101010 \ xor b ;a=GBADCFEH ld b,a ;b=GBADCFEH rrca ;a=HGBADCFE rrca ;a=EHGBADCF rrca ;a=FEHGBADC rrca ;a=CFEHGBAD xor b \ and %01100110 \ xor b ;a=GFEDCBAH rrca ;a=HGFEDCBA