Question

I need some resources to get to know more about numbers with floating point, I need to code add and subtract operations for that kind of numbers in emu8086 environment ....

Any help is much appreciated

Was it helpful?

Solution

As far as I can tell, emu8086 does not emulate a machine with an 8087 FPU.

Any floating-point you do has to be pure software, not using fld / fadd / fstp or any of the usual legacy1 x87 instructions.

If you want to use FP instructions in real mode, your best bet is an emulator like DOSBox or BOCHS that emulate a more recent x86 + x87, not emu8086. This also has the advantage of letting you use more convenient instructions like imul ax, 1234 instead of having to use 1-operand mul.

If you are stuck with emu8086 (or a real 8086 microcontroller), most problems can be solved with fixed-point, not actually floating point: treat a fixed number of bits as the fractional part. This is easier to do in software with integer instructions. But it still lets you represent numbers like 1.25.


Footnote 1: In modern x86, the x87 FPU is obsolete; we use SSE and SSE2 now for scalar and SIMD FP math, unless 80-bit precision is actually needed. emu8086 of course doesn't have this either. Modern x86 CPUs of course still support x87 instructions; being backwards compatible with existing binaries is x86's primary reason for still existing.

OTHER TIPS

You can implement the addition and subtractions for floating point numbers if you store each number in an array of size 2.

The first block of the array can be the base number and the second being the decimal number (implemented as a regular integer of course).

This may not be the most efficient way, but it is surely possible. Your algorithm will have to take into consideration the way the numbers are stored then perform the ADD and SUB instructions.

You said you didn't want code so I won't post an example, but hopefully this gives you an idea how you can do this on a processor that has no floating point unit.

The 8086 processor doesn't have a floating point unit. There was a floating point coprocessor called the 8087, which was meant to be used with the 8086.

You can see the instruction set for the original 8087 here: http://en.wikipedia.org/wiki/X86_instruction_listings#x87_floating-point_instructions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top