News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Float to string without fpu

Started by drizz, September 15, 2008, 02:32:32 AM

Previous topic - Next topic

jj2007

Excuse my ignorance: Would the same be possible for a REAL10?? Conversion from R4/R8 to R10 is easy...

.data
MyR4 REAL4 123.456
MyR8 REAL8 123.456
MyR10 REAL10 123.456
MyTmp10 REAL10 0.0
.code
fld MyR4
fstp MyTmp10
call drizzconvert
fld MyR8
fstp MyTmp10
call drizzconvert
fld MyR10
fstp MyTmp10
call drizzconvert


drizz

I did plan to code REAL10 version too.
I would just need to enlarge the tables, since Fraction is not greater than 64bits everthing else stays the same (in a nutshell).
The truth cannot be learned ... it can only be recognized.

jj2007

I am looking forward to that :U
Speedwise it looks very promising. Perhaps you can generate the tables once in the uninitialised data section? That's what Dave and I did, using the FPU.

dedndave

#18
numerical computation guide:
http://dlc.sun.com/pdf/819-3693/819-3693.pdf

80-bit real10 format (intel extended reals)


notice that Signaling NaN's require at least one of the lower 63 bits to be set
this is not so for Quiet NaN's

Quiet NaN's and Signaling NaN's may have the sign bit set to 1

the value: ffff c0000000 00000000 is an "Indefinate"
a special case of the set of Quiet NaN values

all other values are "Invalid"

Astro

Great explanation! Thankyou!  :thumbu  :8)

Best regards,
Astro.

drizz

Here it is!

Now, it isn't finished yet, this is just a test version that has 18-digit precision.
I couldn't make it work for 19 digits (yet).

I would probably need to recheck the tables or add some special handling to support all 19 digits.

play around and see if you can find some bugs.

:8)
The truth cannot be learned ... it can only be recognized.

2-Bit Chip

#21
Looks advanced!

I just have a question about:

mov ebx,[esp+2*4][4*4][locals]

How in the world is this legal?! :dazzled:

dedndave

lol
it's just assembler syntax
it makes it easier to understand where the values came from
"2*4", "4*4", and "locals" are all essentailly constants that get added together
if he just put the number in there, it may not be as easy to figure out how he arrived at that constant

drizz

Quote from: 2-Bit Chip on August 30, 2009, 07:52:36 AMmov ebx,[esp+2*4][4*4][locals]
parameters are accessed through stack to free ebp for other use.
it means:
[esp+second argument][size of registers pushed ][size of local variables]
2*4,4*4;;  4 means size of DWORD
2*DWORD,4*DWORD

(second argument actually in this case means higher dword of r8 since real8 is 8 bytes)

concatinated brackets in masm mean "plus"
mov eax,[edx][0][0][0][0][0][0][0][0]
will work just fine

The truth cannot be learned ... it can only be recognized.

jj2007

Quote from: drizz on August 26, 2009, 05:24:56 PM
I would probably need to recheck the tables or add some special handling to support all 19 digits.

play around and see if you can find some bugs.

Looks fine and is bloody fast, compliments :U
The only open question is if you could not generate the table in the .data? section, in order to avoid that bloat feeling ::)

3,14159265358979324
3.141592653589793238
369     drizz
630     Str$ JJ