So, does anyone know how to print a floating point number in NASM? I'm trying to create a pi approximator for my "pi in nearly every language" series of repls in NASM (by the request of @CodeLongAndPros) and when I try to print a floating point number, it shows random characters (like
�[email protected] for example) instead of numbers. I already tried using
gcc and it said the file didn't exist, so I'm not sure what to do.
Hey! Rather than call out to libc I decided to see if I could hack out just enough machinery to print a float using only the tools you used.
Here's the best I could do! https://repl.it/@Zekka/NASM-Pi-float-printing-demo
@AmazingMech2418 First, I've opened the ask column. But it seems like there is an error in my account because before I submit it comes out first.
Second, I have an assignment to divide sentences into several words with regex. Example I have the variable txt = "Eid night". In my assignment the first thing to do is to delete whitespace and I've done it here. then I have to divide the sentence in txt with the divisor that I entered like div = 4. so that the output will be ["eidn", "idni", "dnig", "nigh", "ight"]. Can you help me to solve this problem?
!) This is ASM, not NASM,
2) As far as I know, you can't print numbers in ASM, (I may be wrong), but you'd be better off converting it into a string.
Your number is being read as a string, instead of getting a bunch of decimals it's just giving some low ASCII points. Also, your math might be off.
1) It is Assembly, but specifically using the NASM assembler, making it NASM. I also am using the NASM syntax as well.
2) The only issue is that I don't know how to convert a float to a string in Assembly. Also, I was just testing the printing of floats, so the math is definitely off because I didn't intend for the same math to be used in the final pi approximator.