have a little function that takes a string and can extract usable number out of the string for math. now i need to be able to take a value in ax and convert it back to something the user understands.
had it working. lost the code and cant rememeber even were to start.
converting issue binary - decimal (assembly)
-
- Member
- Posts: 62
- Joined: Fri Jun 29, 2007 8:36 pm
See this topic for an example in code (if you need one):
http://www.osdev.org/phpBB2/viewtopic.php?p=99014#99014
http://www.osdev.org/phpBB2/viewtopic.php?p=99014#99014
-
- Member
- Posts: 62
- Joined: Fri Jun 29, 2007 8:36 pm
- liquid.silver
- Member
- Posts: 46
- Joined: Sat Jun 30, 2007 12:07 pm
- Location: South Africa
- Contact:
Sorry for the off-topic post, but don't you mean "sweet"? It made me laugh though, so it was funnyNinjarider wrote:thnx much you'll answer what was going to be my next question. sweat.
im not able to access it but does anyone of the top of there heads rmemeber what that command is in asm.
never mind just found an online refrence. sweat
This would print the number in reverse order. You must use recursion to print the number correctly.divide by 10, print the remainder, repeat until the result is 0.
-
- Member
- Posts: 62
- Joined: Fri Jun 29, 2007 8:36 pm
quick silver
thnx for correcting my misspelling on that. its just somthing i say when i either get something to work or understand something.
as far as recursion. if done correctly there is no recursion of any sort needed at all. if you know the length that the number wil make you can createa a buffer call x to hold {lets say 10 characters} create another label or variable right at the end of it called y
std \set our direction flag
mov di, offset y -1
@@: \the begining of our loop
...
... \all our code to break register (e)ax to characters
stosb
... \check to see if our register has reached 0
cld \clear our direction flag
then when your done you can print the string x and the null (0) characters will not appear (if there are any). so by doing this we need no recursion.
if you ask how it works:
if we have a variable x and that variable starts at linear address 7e00h
we then set di equal to the 7e00h
if the direction flag is clear. when we move information to ram using the stos function it will store the character for you and increment di properly for us. so that the next stor function would put a character at 7e01h
with the direction flag set. whenever we use a stor function to move something to memory it decrements di so that the next character would be stored at 7dffh
thats atleast in assembly
thnx for correcting my misspelling on that. its just somthing i say when i either get something to work or understand something.
as far as recursion. if done correctly there is no recursion of any sort needed at all. if you know the length that the number wil make you can createa a buffer call x to hold {lets say 10 characters} create another label or variable right at the end of it called y
std \set our direction flag
mov di, offset y -1
@@: \the begining of our loop
...
... \all our code to break register (e)ax to characters
stosb
... \check to see if our register has reached 0
cld \clear our direction flag
then when your done you can print the string x and the null (0) characters will not appear (if there are any). so by doing this we need no recursion.
if you ask how it works:
if we have a variable x and that variable starts at linear address 7e00h
we then set di equal to the 7e00h
if the direction flag is clear. when we move information to ram using the stos function it will store the character for you and increment di properly for us. so that the next stor function would put a character at 7e01h
with the direction flag set. whenever we use a stor function to move something to memory it decrements di so that the next character would be stored at 7dffh
thats atleast in assembly