1 2#include <asm.inc> 3#include <ks386.inc> 4 5/* 6 * void *memset (void *src, int val, size_t count) 7 */ 8 9PUBLIC _memset 10.code 11 12FUNC _memset 13 FPO 0, 3, 4, 1, 1, FRAME_NONFPO 14 push ebp 15 mov ebp, esp 16 push edi 17 mov edi, [ebp + 8] 18 movzx eax, byte ptr [ebp + 12] 19 mov ecx, [ebp + 16] 20 cld 21 cmp ecx, 16 22 jb .L1 23 mov edx, HEX(01010101) 24 mul edx 25 mov edx, ecx 26 test edi, 3 27 je .L2 28 mov ecx, edi 29 and ecx, 3 30 sub ecx, 5 31 not ecx 32 sub edx, ecx 33 rep stosb 34 mov ecx, edx 35.L2: 36 shr ecx, 2 37 rep stosd 38 mov ecx, edx 39 and ecx, 3 40.L1: 41 test ecx, ecx 42 je .L3 43 rep stosb 44.L3: 45 pop edi 46 mov eax, [ebp + 8] 47 leave 48 ret 49ENDFUNC 50 51END 52