Testing Math Coprocessor Instructions FLD FADD FSTP FST

Last reviewed: January 6, 1995
Article ID: Q59127
The information in this article applies to:
  • Microsoft Macro Assembler for MS-DOS, version 5.1

The following code was used to view coprocessor instructions on an 80386 machine with an 80387 coprocessor. It is a combination of the examples on Pages 384 and 385 of "Microsoft Macro Assembler 5.1 for the MS-DOS Operating System Programmer's Guide."

               .model small
               .386
               .387
               .stack 100h
               .data
      m1       dd   1.0
      m2       dd   2.0
               .code
      start    proc
               mov ax, @data ;load address of segment
               mov ds,  ax   ;     register
               fld   m1      ;push m1 into st(0)
               fld   m2      ;push m2 into st(0)
               fadd  m1      ;add m2 to st(0)
               fstp  m1      ;pop st(0) into m1
               fst   m2      ;copy st(0) into m2

               fld1          ;push 1 into st(0)
               fldpi         ;push pi into st(0)
               fadd          ;add st(0) and st(1)
                             ;and pop, place result in st(0)
      start    endp
               end  start

While assembling the above code, the .386 and .387 directives must be placed below the .model directive to generate 16-bit segments. If placed above the .model directive, 32-bit segments will be generated and will produce erroneous results, as 32-bit segments cannot be run under DOS.

While running the code through CodeView, the number 7 entered in the dialog box displays a dump of the present status of the chip.


Additional reference words: 5.10
KBCategory: kbprg
KBSubCategory: MASMLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 6, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.