Skip to content

Instantly share code, notes, and snippets.

@runer112
Last active September 2, 2016 16:02
Show Gist options
  • Save runer112/af339a3ec337c45d8e32539e2e74c88f to your computer and use it in GitHub Desktop.
Save runer112/af339a3ec337c45d8e32539e2e74c88f to your computer and use it in GitHub Desktop.
Optimized memset_fast to 25 bytes
; (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