Search code examples
assemblyx86-16emu8086x87

Assembly 8086; Floating Point Numbers, Add, Subtract


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


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.