News:

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

Floating point emulation

Started by Gunther, November 15, 2010, 06:20:18 PM

Previous topic - Next topic

Gunther

I've to write a bit software for an embedded system (80386 CPU, unfortunately without 80387). So, I need a good 32 bit floating point emulation library. Can anyone help?

Gunther
Forgive your enemies, but never forget their names.

japheth

Quote from: Gunther on November 15, 2010, 06:20:18 PM
I've to write a bit software for an embedded system (80386 CPU, unfortunately without 80387). So, I need a good 32 bit floating point emulation library. Can anyone help?

I've created such a "library" ( it is a dll in PE format, based on the Open Watcom 387 emulation code ).

However, I'm selling it ( source + binary ).

Gunther

Quote from: japheth, November 15, 2010, at 06:32:26 PMI've created such a "library" ( it is a dll in PE format, based on the Open Watcom 387 emulation code ).

That doesn't help much, because the OS is Open DOS.

Gunther
Forgive your enemies, but never forget their names.

clive

Does it have to emulate, or could you just use a floating point library that doesn't use the x87 at all. Watcom, my favorite 386 era 32-bit compiler had MATH3R.LIB and MATH3S.LIB to do exactly this.
It could be a random act of randomness. Those happen a lot as well.

japheth

Quote from: Gunther on November 15, 2010, 07:19:41 PM
Quote from: japheth, November 15, 2010, at 06:32:26 PMI've created such a "library" ( it is a dll in PE format, based on the Open Watcom 387 emulation code ).

That doesn't help much, because the OS is Open DOS.

If "OpenDOS" is MS-DOS compatible, it's no problem. However, a requirement is that your software has to run in 32-bit protected-mode

Gunther

Quote from: clive, , November 15, 2010, 07:31:11 pmDoes it have to emulate, or could you just use a floating point library that doesn't use the x87 at all.

Clive, the trick is that there isn't much memory and only a small hard disk. I can't use HLL and therefore, the applications must be written in assembly language. The best solution would be the usage of emulation procedures at the source code level.

Quote from: japheth, November 15, 2010, 07:35:25 pmHowever, a requirement is that your software has to run in 32-bit protected-mode

I've to check that.

Gunther
Forgive your enemies, but never forget their names.

dedndave

using a good library can work as well as emulated FP
in some ways, a library is better because it can perform entire functions, rather than emulating single instructions
emulated FP code isn't all that fast   :P
shouldn't be much difference between the two, in terms of size
the main advantage of emulated code is, you can easily run the same code on machines that have an FPU and those that don't

the problem you are going to have is finding it   :bg
everyone is used to having an FPU present

i have a very old 16 bit lib that i wrote back in the 80's
it wouldn't be much use to you, i'm afraid
i may update it someday, just as a math refresher   :P

clive

Quote from: Gunther on November 16, 2010, 03:12:15 AM
Clive, the trick is that there isn't much memory and only a small hard disk. I can't use HLL and therefore, the applications must be written in assembly language. The best solution would be the usage of emulation procedures at the source code level.

Exactly how small? I'm used to working with 128KB or less in ROM/FLASH, and no hard-drive. It is not as if emulating the 387 instruction set is free of substantial costs in speed/space, and it has to emulate all possible instructions, rather than a well written float library which will actually dump unused functionality. Now you could implement a subset, but that has to be clearly documented, so that someone down the road doesn't assume that because it compiled/linked that it is going to work.

The 32-bit 387 emulation package in Microsoft C 7 had a 16-20KB footprint. Watcom's 387 EMU is pushing close to 20KB. Both are almost certainly hand coded assembler.
It could be a random act of randomness. Those happen a lot as well.

FORTRANS

Hi,

   Until you find a 32-bit solution, you can try out EM87 on
this site (a TSR).  Not perfect, but it works okay on most FPU
instructions.

EM87 (13 KB)
Version 1.2 by Ron Kimball

http://hp200lx.net/super2.html

Regards,

Steve N.

Gunther

I could solve my problem. I need only addition, subtraction, multiplication, and division of floating point numbers; so I've written that small library and it works well.

Gunther
Forgive your enemies, but never forget their names.

dedndave

oh - that's easy stuff - lol
it is things like exponentiation and trig functions that are hard to perfect

Gunther

Quote from: dedndave, November 17, 2010, at 03:57:14 PMoh - that's easy stuff - lol

Yes, easy to write.

Quote from: dedndave, November 17, 2010, at 03:57:14 PMthings like exponentiation and trig functions that are hard to perfect

Yep, Taylor series, CORDIC algorithms etc. A hard job.

Gunther
Forgive your enemies, but never forget their names.