section .data
c: db 0
section .text
myputchar:
pusha
mov [c], al
mov ecx, c mov edx, 1 mov ebx,1 mov eax,4 int 0x80
popa
ret
global _start
_start:
push 12340
call print_integer
mov al, 10
call myputchar
push -842101
call print_integer
mov al, 10
call myputchar
push 0
call print_integer
mov al, 10
call myputchar
mov eax, 1
int 0x80
print_integer:
push ebp
mov ebp, esp
pusha
mov eax, [ebp+8]
cmp eax , 0
jnl check2
mov al, '-'
call myputchar
mov eax, [ebp+8]
neg eax
push eax
call print_integer
jmp endfunc
check2:
cmp eax, 10
jge recur
add al, '0'
call myputchar
jmp endfunc
recur:
mov edx, 0
mov ecx, 10
div ecx
push eax
call print_integer
mov al, dl
add al, '0'
call myputchar
endfunc:
popa
mov esp, ebp
pop ebp
ret 4