Z80 Routines:Optimized:reverseA: Difference between revisions

From WikiTI
Jump to navigationJump to search
Galandros (talk | contribs)
New page: reverseA reverseA reverseA This is a faster/smaller (and also obfuscated) replacement for t...
 
Galandros (talk | contribs)
mNo edit summary
Line 1: Line 1:
[[Category:Z80 Routines:Optimized|reverseA]]
[[Category:Z80 Routines:Optimized|ReverseA]]
[[Category:Z80 Routines:Graphic|reverseA]]
[[Category:Z80 Routines:Graphic|ReverseA]]
[[Category:Z80 Routines|reverseA]]
[[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 35: Line 34:
;18 bytes and 66 clock cycles
;18 bytes and 66 clock cycles
;author: calcmaniac84
;author: calcmaniac84
reverseA:
ReverseA:
ld b,a
ld b,a
rrca
rrca

Revision as of 22:15, 26 October 2009

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
;18 bytes and 66 clock cycles
;author: calcmaniac84
ReverseA:
	ld b,a
	rrca
	rrca
	xor b
	and %10101010
	xor b
	ld b,a
	rrca
	rrca
	rrca
	rrca
	xor b
	and %01100110
	xor b
	rrca
	ret