flat assembler
Message board for the users of flat assembler.
Index
> Main > ASCII to Float (r80) algorithm |
Author |
|
vid 21 Feb 2007, 00:29
FASM sources contain something like that in parser. ask tomasz for further pointing.
|
|||
21 Feb 2007, 00:29 |
|
Chewy509 21 Feb 2007, 01:35
vid wrote: FASM sources contain something like that in parser. ask tomasz for further pointing. I've read through the fasm source, but really can't make head or tail of it? |
|||
21 Feb 2007, 01:35 |
|
farrier 21 Feb 2007, 08:50
Chewy509,
You can look at Raymond Filiatreault's site where he has an FPU Tutorial, FPULib--with MASM source--, Complex number, Fixed Point Math, and Binary Coded Decimal sections. Designed for teaching/learning to use these tools! http://www.ray.masmcode.com/ hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
21 Feb 2007, 08:50 |
|
shoorick 21 Feb 2007, 09:06
check a2f in shoolib - i wrote it long ago after study similar masm32 function. it exactly eats string into 80-bit float (thus possible slow) and has no restrictions on string length i had not wrote f2a yet (as i had no neccessity in it yet), but there are a lot of ready examples.
_________________ UNICODE forever! |
|||
21 Feb 2007, 09:06 |
|
vid 21 Feb 2007, 09:53
also note that FASM's a2f doesn't use FPU and so it has much better precision
|
|||
21 Feb 2007, 09:53 |
|
Chewy509 22 Feb 2007, 01:06
Thanks guys. I'll check out those links.
Vid, after rereading the fasm source, I noticed that it doesn't use the FPU, a little strange, but if it works, it works. I guess that was stuffing me up when looking through the source, as I was expecting some FPU code? |
|||
22 Feb 2007, 01:06 |
|
ChrisLeslie 22 Feb 2007, 04:22
Quote from shoorick:
Quote: i had not wrote f2a yet (as i had no neccessity in it yet), I am curious as to how you can visualise any final output floats that you may have produced without an f2a? Chris |
|||
22 Feb 2007, 04:22 |
|
shoorick 22 Feb 2007, 05:39
i saw it in debugger
|
|||
22 Feb 2007, 05:39 |
|
Chewy509 23 Feb 2007, 00:53
I've been thinking a lot about this recently and have looked at about 30 implementations of the atof(), however 1 implementation stood out in that it doesn't use lookup tables for the exponent and to be honest appears really simple.
It basically is along the lines of: Code: FILD word [exp] ; st0 = exponent FLDL2T ; st0 = log2_10, st1 = exponent FMULP st1; st0 = exp * log2_10 FBLD [sig] ; st0 = sig, st1 = exp FSCALE ; st0 = st0 * 2 ^ st1 if value is neg then FCHS done! exp is the exponent biased accordingly for the imported significant taking into account the movement of the decimal when converting the significant to BCD. eg: 100.123456e99, would be sig as bcd when loaded = 100123456 exp = 93 (as the decimal shits right we sub the places from exp, if decimal shifts left we add to the exp the number of places) So how does it work? Well since we don't have a x^y instruction, we need to use: x^y = 2^ (y * log2_x) or since we are using 10 ^ y 10^y = 2 ^ (y * log2_10) . The great thing is, is that the x87 FPU contains log2_10 as a constant! eg FLDL2T! And since our original form is: sig * 10 ^ exp we can use: sig * (2 ^ (exp * log2_10)) based on the above knowledge. Can anyone find anything wrong with this approach? Or did I miss something during my high school math classes? |
|||
23 Feb 2007, 00:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.