Message board for the users of flat assembler.
> Examples and Tutorials > Double-Precision to String & Friends. FPU-based conversi
This is straight out from the oven
These routines deal with FPU-based conversions for double and single precision: Float/Double to String (prtflt,prtdbl) and String to Float/Double (getflt,getdbl). Plus other useful routines for newbies dealing with precision data.
The routines objectives:
1. To open up new opportunities for newbies and learners to deal with precision data while learning assembly. No more integer-only assembly programming. Now you can see what's in the FPU stack as you program them.
2. To demonstrate the basic steps in FPU conversion both ways by using only FPU instructions and two basic C/OS library - putchar and getchar.
1. prtdbl - display REAL8 precision data (dq). Send the address
2. prtflt - display REAL4 precision data (dd). Send the value
3. getflt - get a float data from keyboard
4. getdbl - get a double-precision data from keyboard
5. fpbin - Display binary format of a real4 data
6. fpbinq - Display binary format of a real8 data. Send the address
7. fpu_stack - Display FPU stack
8. fpu_sflag - Display FPU status flag
9. fpu_cflag - Display FPU control flag
- The file is ready to compile and run.
- These routines are far from perfect. I coded them as it goes, as a hobby, based on my limited knowledge on ASM
- Routines are slow. I put no emphasis on optimization or efficiency, plus, there could be some hidden bugs somehere. You are welcome to improve it and post it back here.
- The import table at the end of code must be left alone.
- Excuse the lack of comments. I don't intent to put comments until all bugs are figured out. Deleting side-comments for 1000-line codes is simply a PITA!
- Macro version is available. But I don't think you are interested.
Last edited by fasmnewbie on 24 Sep 2014, 14:29; edited 1 time in total
|24 Sep 2014, 04:21||
Test program and output (it's included in the attachment).
format pe console ;Flat PE include 'win32axp.inc' stdcall fpbinq,z,1 ;Display normalized binary