putint function not working
Posted: Fri Sep 11, 2015 8:37 pm
hello, i have written this function to print in base 10 an integer.
putc which it calls,takes dl as character and cl as color code
when i call putint with eax at 1024 it outputs 3 and a half lines of '5' then does nothing. can anyone tell me what I'm doing wroing?
putint:
.printdigit:
cmp eax, 0
je .zero
mov ebx, 10
push edx
div ebx
mov dl, '0'
add dl, al
mov cl, 7
call putc
mov eax, edx
pop edx
jmp .printdigit
.zero:
mov dl, '0'
mov cl, 7
call putc
ret
putc which it calls,takes dl as character and cl as color code
when i call putint with eax at 1024 it outputs 3 and a half lines of '5' then does nothing. can anyone tell me what I'm doing wroing?
putint:
.printdigit:
cmp eax, 0
je .zero
mov ebx, 10
push edx
div ebx
mov dl, '0'
add dl, al
mov cl, 7
call putc
mov eax, edx
pop edx
jmp .printdigit
.zero:
mov dl, '0'
mov cl, 7
call putc
ret