Difference between revisions of "Z80 Routines:Optimized:StrCopy"

From WikiTI
Jump to: navigation, search
 
(not all assemblers support the $$ and $b thing. Example: spasm)
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
 
;Destroys AF, DE, HL
 
;Destroys AF, DE, HL
 
xor a ;4
 
xor a ;4
$$:
+
docopystr:
 
cp (hl) ;7
 
cp (hl) ;7
 
ldi ;16
 
ldi ;16
jr nz,$b ;12
+
jr nz,docopystr ;12
 
ret ;5</nowiki>
 
ret ;5</nowiki>
 
Change jr to jp to save a couple clocks and add a byte.
 
Change jr to jp to save a couple clocks and add a byte.

Latest revision as of 01:59, 9 November 2009


StrCopy:
;Copy zero terminated string at HL to DE.
;Destroys AF, DE, HL
	xor	a		;4
docopystr:
	cp	(hl)		;7
	ldi			;16
	jr	nz,docopystr	;12
	ret			;5

Change jr to jp to save a couple clocks and add a byte.