I've been trying to write an assembly procedure that prints a number.
I wrote the procedure printc that prints a single character:
printc: push    ebp
        mov     ebp, esp
        mov     eax, 4
        mov     ebx, 1
        add     [ebp + 8], byte '0' 
        lea     ecx, [ebp + 8]
        mov     edx, 1
        int     0x80
        mov     esp, ebp
        pop     ebp
        ret
Then I tried to write printi so:
printi: push    ebp
        mov     ebp, esp
        mov     eax, [ebp + 8]
        cmp     eax, 0
        je      end
        mov     ebx, 10
        div     ebx
        push    eax
        call    printi
        push    edx
        call    printc
end:    mov     esp, ebp
        pop     ebp
        ret
Finally, I called printi:
_start: push    32 
        call    printi
And got Segmentation fault (core dumped).
Any idea why?
 
    