News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Potential Fpulib ugrade

Started by raymond, February 04, 2016, 07:28:14 AM

Previous topic - Next topic

raymond

Based on questions about any future mods to the Fpulib (to which I previously replied NO), I have been thinking of modifying all functions to allow the use of 32-bit and 64-bit floats for inputs and outputs (in addition to the current strictly 80-bit size). Obviously this would require some additional overhead and an update to the help file.

Would the effort be really worth it?

While at it, could this "32-bit" lib be modified in such a way that it could also be used with a 64-bit linker? For instance, all references to memory locations are currently expecting a dword. Expert advice would be a necessity.
Whenever you assume something, you risk being wrong half the time.
https://masm32.com/masmcode/rayfil/index.html

dedndave

my thoughts....

wouldn't it be easier to write a seperate set of routines for each size ?
probably faster performance, too

personally, i use 80-bit whenever practical to do so
but, some functions want or return 4 or 8 byte reals, so i convert

farrier

My WishList would include an official 32 and 64 bit DLL version of the library.

This would "simplify" "Linking" with almost any windows program.

I asked for, and received permission from Raymond to construct a DLL version.
so that I can easily use the FPU library with my fasm programs without having
to use a linker. fasm can create programs and DLL's without a linker, if there
are no required .lib or .obj files.

Thanks to Raymond for a valuable learning and everyday tool.

Thanks,

farrier

raymond

Quote from: dedndave on February 05, 2016, 06:31:54 AMwouldn't it be easier to write a seperate set of routines for each size ?
probably faster performance, too

The library is not designed for speed but to help programmers start using floats before learning how to use the FPU themselves in the most efficient manner.

A separate set of routines for each size would mainly bloat the exe unnecessarily with possibly three copies of almost identical procedures. Allowing the three sizes within the same procedure would only require testing the uID for additional bits in the overhead (there still are some 16 unused bits available for the uID). Default would still be the 80-bit size throughout to maintain compatibility with older scripts.
Whenever you assume something, you risk being wrong half the time.
https://masm32.com/masmcode/rayfil/index.html

dedndave

the library would get bigger
but, the linker only pulls in the modules that are used
it's unlikely that a program would require the same function for all 3 sizes

FORTRANS

Hi,

Quote from: raymond on February 04, 2016, 07:28:14 AM
Based on questions about any future mods to the Fpulib (to which I previously replied NO), I have been thinking of modifying all functions to allow the use of 32-bit and 64-bit floats for inputs and outputs (in addition to the current strictly 80-bit size). Obviously this would require some additional overhead and an update to the help file.

Would the effort be really worth it?

   If I understand correctly (ha), the FPUlib is for beginners.  As such
keeping things simple should be a consideration.  Keep using 80-bit
reals and provide examples, or routines, to convert from the other
sizes.  It is just two lines of code, correct?  FLD Short, FSTP TenByte,
or some such.

$.02,

Steve N.

jj2007

In my fairly long experience with Raymond's work, I found that the Simply FPU tutorial is far more interesting than the library, which I used only for a very short period. The reason is mainly that the FPU looks complicated but in reality is easy to use, provided you have good learning material. And Ray's tutes are by far the best you can get (really, no joke, there is nothing better on the market).

Once you've overcome the initial reluctance to learn a completely new set of instructions, practicing helps. One option is OllyDbg, but for those who are not scared of using an external library, the deb macro is a faster way to learn what the FPU does:

include \masm32\MasmBasic\MasmBasic.inc      ; download
.data
MyR8      REAL8 123456789.123456789
MyR10     REAL10 ?

  Init
  fldpi
  deb 4, "Fpu at start, PI loaded", ST(0), ST(1), ST(2), ST(3), ST(4)
  fld MyR8
  deb 4, "after fld MyR8", ST(0), ST(1), ST(2)
  fldpi
  deb 4, "after fldpi", ST(0), ST(1), ST(2)
  fmul
  deb 4, "after fmul", ST(0), ST(1), ST(2)
  fld FP10(87850941.7460361441)
  deb 4, "after fld fp10", ST(0), ST(1), ST(2)
  fsub
  deb 4, "after fsub", ST(0), ST(1), ST(2)
  push 30000
  fidiv dword ptr [esp]      ; what happens if you use word ptr instead of dword ptr?
  deb 4, "after fidiv", ST(0), ST(1), ST(2)
  fxch
  deb 4, "after fxch", ST(0), ST(1), ST(2)
  fstp MyR10
  deb 4, "after fstp", ST(0), ST(1), ST(2), MyR10
  fistp dword ptr [esp]
  pop eax
  deb 4, "after fistp", ST(0), ST(1), ST(2), eax
EndOfCode


Output:
Fpu at start, PI loaded
ST(0)           3.141592653589793238
ST(1)           0.0
ST(2)           0.0
ST(3)           0.0
ST(4)           0.0

after fld MyR8
ST(0)           123456789.1234567910
ST(1)           3.141592653589793238
ST(2)           0.0

after fldpi
ST(0)           3.141592653589793238
ST(1)           123456789.1234567910
ST(2)           3.141592653589793238

after fmul
ST(0)           387850941.7460361442
ST(1)           3.141592653589793238
ST(2)           0.0

after fld fp10
ST(0)           87850941.74603614410
ST(1)           387850941.7460361442
ST(2)           3.141592653589793238

after fsub
ST(0)           300000000.0000000001
ST(1)           3.141592653589793238
ST(2)           0.0

after fidiv
ST(0)           10000.000000000000002
ST(1)           3.141592653589793238
ST(2)           0.0

after fxch
ST(0)           3.141592653589793238
ST(1)           10000.000000000000002
ST(2)           0.0

after fstp
ST(0)           10000.000000000000002
ST(1)           0.0
ST(2)           0.0
MyR10           3.141592653589793238

after fistp
ST(0)           0.0
ST(1)           0.0
ST(2)           0.0
eax             10000

HSE

I agree with later concepts. I read the tutorial and read the library, but I never run the library (and the main purpose is fullfilled).  Ok, perhaps fullfilled: Raymond you can't select the students...  most of us?  :biggrin:

Regards. HSE
Equations in Assembly: SmplMath