I'm trying to implement memset in assembly x86. both with a copy by byte and by word, so I'd get two functions: `kmemset` and `kmemsetw` that I expose to my C code this way: 

```
extern uint8_t* kmemset(uint8_t* dest, uint8_t val, uint8_t size);  
extern uint16_t* kmemsetw(uint16_t* dest, uint16_t val, uint8_t size);  

```

problem is when I test it, I get a segmentation fault. I tried to debug with gdb but it doesn't seem to be able to step into the asm code. I would be happy if anyone could comment on the code. (`kmemset` is pretty similar so I didn't include it). 

```
.intel_syntax noprefix  
.section .text  
.align 16  
.global kmemsetw  
.type kmemsetw, @function  

kmemsetw:  
    push ebp  
    mov ebp, esp  
    push edi  
    push ecx  
    push ebx  
    xor eax, eax  
    mov ebx, [ebp+4]  
    mov ax, [ebp+8]  
    mov ecx, [ebp+12]  
    mov edi, ebx  
    rep stosw  
    mov eax, edi  
    pop ebx  
    pop ecx  
    pop edi  
    pop ebp  
    ret  

```