2 ; void* memset (void* ptr, int c, size_t n);
4 ; Ullrich von Bassewitz, 29.05.1998
9 .importzp ptr1, ptr2, tmp1, tmp2, tmp3
18 stx ptr1+1 ; Save work copy
20 stx ptr2+1 ; Save a copy for the function result
24 ldx tmp2 ; Get high byte of n
29 L1: sta (ptr1),y ; Set one byte
31 sta (ptr1),y ; Unroll this a bit to make it faster
35 dex ; Next 256 byte block
36 bne L1 ; Repeat if any
38 ; Set the remaining bytes if any
40 L2: ldx tmp1 ; Get the low byte of n
41 beq L9 ; Low byte is zero
43 L3: sta (ptr1),y ; Set one byte
48 L9: lda ptr2 ; Load function result