Skip to content

Instantly share code, notes, and snippets.

@jacobly0
Forked from runer112/memset_fast.asm
Last active September 2, 2016 16:11
Show Gist options
  • Save jacobly0/95198d34e859f6f768ed325bc8a19658 to your computer and use it in GitHub Desktop.
Save jacobly0/95198d34e859f6f768ed325bc8a19658 to your computer and use it in GitHub Desktop.
Optimized memset_fast to 23 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
cpi
add hl,bc
ret c
dec hl
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