Last active
September 2, 2016 16:02
-
-
Save runer112/af339a3ec337c45d8e32539e2e74c88f to your computer and use it in GitHub Desktop.
Optimized memset_fast to 25 bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; (c) Copyright 2016 Matt Waltz | |
;------------------------------------------------------------------------- | |
; Faster memset variation | |
; Reasons faster: | |
; 1) uses ldir to memset | |
; 2) executes in RAM to avoid flash wait states | |
;------------------------------------------------------------------------- | |
.def _memset_fast | |
.assume adl=1 | |
_memset_fast: | |
pop iy | |
pop hl | |
pop de | |
pop bc | |
push bc | |
push de | |
push hl | |
push iy | |
dec bc | |
add hl,bc | |
inc hl | |
ret c | |
inc bc | |
cpd | |
ld (hl),e | |
ret po | |
push hl | |
pop de | |
dec de | |
lddr | |
ret | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment