<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Fortan and Masm(ml) floating point examples in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793211#M33735</link>
    <description>You simply have to follow the "C" calling convention and it will be fine. A simple RET will do. RET 4 and the like is when you have chosen to write a STDCALL routine, and you'd then need to tell Fortran it was STDCALL.</description>
    <pubDate>Fri, 16 Mar 2012 14:03:08 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2012-03-16T14:03:08Z</dc:date>
    <item>
      <title>fortan and masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793204#M33728</link>
      <description>&lt;P&gt;Would anyone be able to provide a simple example of a fortran program that calls a masm procedure that does something with floating point, for example, add two doubles and return the result by reference?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2012 21:45:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793204#M33728</guid>
      <dc:creator>MWind2</dc:creator>
      <dc:date>2012-03-10T21:45:17Z</dc:date>
    </item>
    <item>
      <title>fortan and masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793205#M33729</link>
      <description>&lt;P&gt;Well, no. You didn't specify whether you wanted a 32-bit version or a 64-bit version. The calling conventions are different for the two ISAs. Functions would return their result by value, a 32-bit function in ST(0) and a 64-bit version in xmm0. If you want the result returned by reference I suppose you might mean a third, INTENT(OUT) argument to a subroutine.&lt;BR /&gt;&lt;BR /&gt;You can generate your own example by writing a simple Fortran procedure that does no I/O and has the interface you want. Declare it PURE or RECURSIVE and BIND(C) and tell ifort to generate assembly language output. Post the .ASM file produced along with the original .F90 file if you want the forum to analyze it for you.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2012 22:09:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793205#M33729</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2012-03-10T22:09:40Z</dc:date>
    </item>
    <item>
      <title>Fortan and Masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793206#M33730</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;...Would anyone be able to provide a simple example of a fortran program that calls a masm&lt;BR /&gt;&amp;gt;&amp;gt;procedure that does something with floating point...&lt;/P&gt;&lt;P&gt;I could provide an implementation of a function in assembler that adds two Single-Precision&lt;BR /&gt;values and returns the result. Unfortunately, this is from a C/C++ set of tests I have.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="text-decoration: underline;"&gt;Assembler Codes:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; ...&lt;BR /&gt; ; C/C++ Declaration:&lt;BR /&gt; ; float &lt;STRONG&gt;AddTwoSPValues&lt;/STRONG&gt;( float fValue1, float fValue2 );&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;AddTwoSPValues&lt;/STRONG&gt; PROC NEAR&lt;/P&gt;&lt;P&gt; PUSH ebp&lt;BR /&gt; MOV  ebp, esp&lt;/P&gt;&lt;P&gt; FLD DWORD PTR [ebp+8]; Loads &lt;STRONG&gt;fValue1&lt;/STRONG&gt; into &lt;STRONG&gt;ST(0)&lt;/STRONG&gt;&lt;BR /&gt; FADD DWORD PTR [ebp+12]; Adds &lt;STRONG&gt;fValue2&lt;/STRONG&gt; to &lt;STRONG&gt;ST(0)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; MOV  esp, ebp&lt;BR /&gt; POP ebp&lt;BR /&gt;  ; Visual Studio will correct &lt;STRONG&gt;ESP&lt;/STRONG&gt; register and load a result&lt;BR /&gt; RET  ; into an output variable from &lt;STRONG&gt;ST(0)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;AddTwoSPValues&lt;/STRONG&gt; ENDP&lt;BR /&gt; ...&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;BR /&gt;Test-Case in C/C++:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; ...&lt;BR /&gt; float fResult4 = 0.0f;&lt;BR /&gt; float fResultPI = 0.0f;&lt;/P&gt;&lt;P&gt; float fValue1 = 1.0f;&lt;BR /&gt; float fValue2 = 3.0f;&lt;/P&gt;&lt;P&gt; fResult4 = &lt;STRONG&gt;AddTwoSPValues&lt;/STRONG&gt;( fValue1, fValue2 );&lt;BR /&gt; fResultPI = &lt;STRONG&gt;AddTwoSPValues&lt;/STRONG&gt;( 3.0f, 0.1415926f );&lt;/P&gt;&lt;P&gt; printf( "[ Result4: %f ] [ ResultPI: %f ]\n", fResult4, fResultPI );&lt;BR /&gt; ...&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;BR /&gt;Output:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; [ Result4: 4.000000 ] [ ResultPI: 3.141593 ]&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;BR /&gt;Note:&lt;/SPAN&gt;&lt;/STRONG&gt; As soon as a call is done a C/C++ compiler ( Visual Studio 2005 ) corrects &lt;STRONG&gt;ESP&lt;/STRONG&gt; register and&lt;BR /&gt;  loads a result into an output variable from &lt;STRONG&gt;ST(0)&lt;/STRONG&gt;as follows:&lt;/P&gt;&lt;P&gt; ...&lt;BR /&gt; call &lt;STRONG&gt;_AddTwoSPValues&lt;/STRONG&gt;&lt;BR /&gt; add esp, 8&lt;BR /&gt; fstp dword ptr [fResult4]&lt;BR /&gt; ...&lt;BR /&gt; call &lt;STRONG&gt;_AddTwoSPValues&lt;/STRONG&gt;&lt;BR /&gt; add esp, 8&lt;BR /&gt; fstp dword ptr [fResultPI]&lt;BR /&gt; ...&lt;/P&gt;&lt;P&gt; You will need to figure out how toproperly return a valuein case of a &lt;STRONG&gt;Fortran&lt;/STRONG&gt; program.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2012 19:08:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793206#M33730</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-03-15T19:08:26Z</dc:date>
    </item>
    <item>
      <title>Fortan and Masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793207#M33731</link>
      <description>"You will need to figure out how toproperly return a valuein case of a &lt;B&gt;Fortran&lt;/B&gt; program.". and there is the rub, if I recall correctly!&lt;BR /&gt;Notice the RET statement.&lt;BR /&gt;Depending on the calling convention, the RET may or may not have an argument, for example you may have to specify something like RET 4 or some such to clean up the stack.</description>
      <pubDate>Thu, 15 Mar 2012 19:43:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793207#M33731</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2012-03-15T19:43:03Z</dc:date>
    </item>
    <item>
      <title>Fortan and Masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793208#M33732</link>
      <description>I have got some things working with&lt;BR /&gt;&lt;BR /&gt;[fortran]program alo1f
    USE, INTRINSIC :: ISO_C_BINDING
    implicit none
interface
subroutine addrefd( da, db, dc) bind(c)
    !DEC$ ATTRIBUTES C, ALIAS:'_addrefd' ::addrefd    
           real(8),intent(in):: da
           real(8), intent(in):: db
           real(8), intent (inout) :: dc
    !DEC$ ATTRIBUTES REFERENCE :: da
    !DEC$ ATTRIBUTES REFERENCE :: db
    !DEC$ ATTRIBUTES REFERENCE :: dc
          end subroutine addrefd
end interface
    real*8 :: d1 = 76.5
    real*8 :: d2 = 43.1
    real*8 :: d3 = 128.0
    call addrefd(d1,d2, d3) 
end program alo1f
  [/fortran]and &lt;BR /&gt;[plain]addrefd proc C 
        push      ebp                                           
        mov       ebp, esp                                      
        mov       eax, DWORD PTR [ebp+8]                        
        mov       edx, DWORD PTR [ebp+12]                       
        fld       QWORD PTR [eax]                               
        fld       QWORD PTR [edx]                               
        faddp     st(1), st                                     
        mov       eax, DWORD PTR [ebp+16]                       
        fstp      QWORD PTR [eax]                              
        pop ebp   ;leave                                                   
        ret                                                     
addrefd endp[/plain]&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Mar 2012 20:02:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793208#M33732</guid>
      <dc:creator>MWind2</dc:creator>
      <dc:date>2012-03-15T20:02:05Z</dc:date>
    </item>
    <item>
      <title>Fortan and Masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793209#M33733</link>
      <description>A short procedure such as &lt;B&gt;addrefd&lt;/B&gt; does not need its own stack, and since the 80386 we can use the stack pointer in &lt;I&gt;reg/mem&lt;/I&gt; expressions. The following shorter version uses this property.&lt;BR /&gt;[bash]addrefd proc C 
        mov       eax, DWORD PTR [esp+4]                        
        mov       edx, DWORD PTR [esp+8]                       
        fld       QWORD PTR [eax]                               
        fadd      QWORD PTR [edx]                               
        mov       eax, DWORD PTR [esp+12]                       
        fstp      QWORD PTR [eax]                              
        ret                                                     
addrefd endp
[/bash] &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Mar 2012 20:17:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793209#M33733</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-03-15T20:17:15Z</dc:date>
    </item>
    <item>
      <title>Fortan and Masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793210#M33734</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1331873165093="58" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=341673" href="https://community.intel.com/en-us/profile/341673/" class="basic"&gt;anthonyrichards&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;EM&gt;...Depending on the calling convention, the RET may or may not have an argument, for example you may&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt; [&lt;STRONG&gt;SergeyK&lt;/STRONG&gt;] Yes, that's right.&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;have to specify something like RET 4 or some such to clean up the stack...&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;In my case everything is correct because aC/C++ compileruses a forwarddeclarationfor the function:&lt;BR /&gt; ...&lt;BR /&gt; float &lt;STRONG&gt;AddTwoSPValues&lt;/STRONG&gt;( float fValue1, float fValue2 );&lt;BR /&gt; ...&lt;BR /&gt;and addsa cleanupinstruction after the call:&lt;BR /&gt; ...&lt;BR /&gt; call &lt;STRONG&gt;_AddTwoSpValues&lt;/STRONG&gt;&lt;BR /&gt; &lt;SPAN style="text-decoration: underline;"&gt;add esp, 8&lt;/SPAN&gt;&lt;BR /&gt; ...&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2012 04:51:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793210#M33734</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-03-16T04:51:03Z</dc:date>
    </item>
    <item>
      <title>Fortan and Masm(ml) floating point examples</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793211#M33735</link>
      <description>You simply have to follow the "C" calling convention and it will be fine. A simple RET will do. RET 4 and the like is when you have chosen to write a STDCALL routine, and you'd then need to tell Fortran it was STDCALL.</description>
      <pubDate>Fri, 16 Mar 2012 14:03:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/fortan-and-masm-ml-floating-point-examples/m-p/793211#M33735</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-03-16T14:03:08Z</dc:date>
    </item>
  </channel>
</rss>

