Creating an Application w/ FORTRAN and Assembly Language

Last reviewed: July 19, 1995
Article ID: Q33351
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0 and 1.0a

When an application developed in FORTRAN calls a subprogram developed in assembly language, the subprogram must preserve the DS, SS, BP, SI and DI registers and clear the direction flag.

When an application uses the default optimizations, FORTRAN uses the SI and DI registers extensively. An assembly language subprogram that changes SI or DI must save the registers on the stack (with a PUSH instruction) and restore them from the stack (with a POP instruction) before it returns. The FORTRAN code also assumes that the direction flag, used by string functions in assembly language, is always clear. If your assembly language subprogram sets the direction flag (with an STD instruction), it must clear the flag (with a CLD instruction) before it returns.

As a general rule, an assembly language subprogram should also preserve the values of the DS, SS, and BP segment registers (using the PUSH and POP instructions as indicated above).


Additional reference words: kbinf 4.00 4.01 4.10 5.00 5.10 1.00
KBCategory: kbprg
KBSubcategory: FORTLngIss


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: July 19, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.