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
putint function not working
Re: putint function not working
Flip the switch from writing code position to reading code position. And go line by line. See what every instruction does with/to your inputs.
- Combuster
- Member

- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: putint function not working
Which three registers are used by DIV?
Re: putint function not working
(R/E)DX must be null before executing DIV.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
-
glauxosdever
- Member

- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: putint function not working
Hi,
zerorax: If you are being serious, study carefully the code you write and the instructions you use. If not, stop waiting for us to tell you what you are doing wrong.
Regards,
glauxosdever
Combuster wrote:Which three registers are used by DIV?
His code has more flaws than just the DIV assumption.Roman wrote:(R/E)DX must be null before executing DIV.
zerorax: If you are being serious, study carefully the code you write and the instructions you use. If not, stop waiting for us to tell you what you are doing wrong.
Regards,
glauxosdever