NASM Print Floating Point
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
gccand 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
On most modern CPUs, integers and floating point numbers are handled in different ways. Integers are much faster to process in hardware, as there are dedicated circuits for dealing with them quickly. Floating point values have to be dealt with in software, which makes processing them much slower than integers. It's worth noting that the majority of modern programming languages support floats natively so this difference isn't something that programmers have to worry about on a day-to-day basis; however, it can still be important to consider when porting code from one platform to another or when trying to squeeze out the last bit of performance possible from an algorithm.https://printingnearby.com/services-near-by-printing/
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.
- It is Assembly, but specifically using the NASM assembler, making it NASM. I also am using the NASM syntax as well.
- 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.