With Microsoft Macro Assembler (MASM), you can combine the unique strengths of assembly-language programming with Visual Fortran. If you structure your assembly-language procedures appropriately, you can call them from Visual Fortran programs and subprograms. MASM works with Visual Fortran, C, and Visual C++. These high-level languages can call MASM procedures, and each of the languages can be called from MASM programs. Details of the MASM interfaces with the other languages can be found in the Microsoft MASM Programmer's Guide.
Compile your Fortran source module with Visual Fortran, and assemble your assembly-language procedure with the MASM assembler. Then, link the two object files. The following example shows how to call a MASM assembler-language program from Fortran.
The Fortran code:
INTERFACE
INTEGER (4) FUNCTION POWER2 (V,E)
!DEC$ ATTRIBUTES STDCALL :: Power2
INTEGER V, E
END FUNCTION
END INTERFACE
The MASM code:
POWER2 PROTO STDCALL, v, e
...
POWER2 PROC STDCALL, v, e
...
POWER2 ENDP
END
In the example, the Fortran call to MASM is power2(v,e)
, which is identical
to a Fortran function call. Visual Fortran also provides sample mixed-language programs
that show calls between Visual Fortran and MASM (see Examples of
Fortran/MASM Programming).
There are two differences between this mixed-language call and a call between two Fortran modules:
power2(v,e)
is implemented in MASM using standard MASM
syntax. The PROTO declaration in MASM specifies that the procedure use the STDCALL
calling convention. This section covers the following topics: