I'm building an asm kernel based on josh's rudimentary kernel http://www.mohanraj.info/josh4.jsp. I have written a function which converts a single digit to its equivalent char, but now i want to be able to print numbers, not just digits.
This is my plan:
1) divide the [original] by 10 until it is less than 10, saving how many divides it took [n]
2) then print the single digit
3) [m]=10^[n]
4) calculate [original]=[original]-[m]*digit, save [original]
5) do this until [original]!=0
Is this ok?
Thanks a lot!
ps: i'm fairly new to asm
print_int in nasm
Re: print_int in nasm
Don't you think that easier would be to decide first which type of numer your function will display and then divide it every time by base and show the constant from division. Then the rest is the new numer to divide in next loop.
example:
Your function operates on integers from 0 to 2^32 (unsigned long in C).
So you wold have maximum 10 division, starting from dividing by 10^9
and next division is division of the rest from first division by 10^8 etc.
number: 1234567890
gives 1 and rest 234567890.
etc..
I think this is the easiest way .
example:
Your function operates on integers from 0 to 2^32 (unsigned long in C).
So you wold have maximum 10 division, starting from dividing by 10^9
and next division is division of the rest from first division by 10^8 etc.
number: 1234567890
gives 1 and rest 234567890.
etc..
I think this is the easiest way .
Re: print_int in nasm
I guess that would be easier...
Thanks, I'll give it a whirl,
norc-
Thanks, I'll give it a whirl,
norc-