home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,696 of 4,675   
   Rick C. Hodgin to NimbUs   
   Re: interfacing ASM (ia-32) with GNU g77   
   23 Jun 17 13:25:33   
   
   From: rick.c.hodgin@nospicedham.gmail.com   
      
   On Friday, June 23, 2017 at 3:54:46 PM UTC-4, NimbUs wrote:   
   > Hello, Group ! I posed a similar to question in title in a   
   > Fortran n.g., got no detailed reply, THEN it occurred to me I   
   > should have asked HERE first :=)   
   >   
   > I need guidance and, if possible, a template for writing a   
   > "subroutine" callable from GNU Fortran - specifically, g77.   
   > Let's say, having a couple of long integer (integer*8)   
   > parameters.   
   >   
   > First dilemma : which assembler to choose ? I would much   
   > rather use  Intel/Microsoft MASM/TASM-like over ATT/GAS. My   
   > ASM of choice in general is TASM - but it outputs only   
   > Intel/MS-style "OMF" modules, is that a problem for the GNU   
   > "ld" linker, as I suspect it would be ? Needed an auxiliry   
   > step/prgram for converting to "Coff" - or whatever format GNU   
   > uses ? Would FASM, for instance, be a more natural choice of   
   > an assembler for achieving the stated goal?   
   >   
   > Please also remind me of the calling conventions used by GNU   
   > Fortran on ia32 for parameter passing/clearing of the stack...   
   >   
   > It would be nice if we could have a peek at a short   
   > sample/template written in the appropriately proposed ASM   
   > dialect !   
   >   
   > TIA   
   >   
   > --   
   > NimbUs   
      
   You can use Visual Studio to write your assembler code if you   
   want.  That way you have the full debugger IDE to help you debug   
   your call into the assembly function, examine the call stack,   
   parameter order, etc., and make sure everything's working.   
      
   It supports assembly using:   
      
       _asm {   
           // Put your assembly here   
       }   
      
   You can also use a standard calling convention for your call   
   into the code, receiving parameters, and returning them using   
   a traditional C template, as in:   
      
       int my_add_function(int p1, int p2)   
       {   
           int result;   
      
           _asm {   
               // All your custom code goes here   
               // Note:  That the 64-bit calling convention places   
               //        the first parameters in registers, so you   
               //        can directly access them   
      
               // Add them   
               add   rcx, rdx   
      
               // Store the result   
               mov   result,rcx   
           }   
      
           return(result);   
       }   
      
   It adds some overhead, but sometimes it's easier to code and   
   debug.   
      
   Thank you,   
   Rick C. Hodgin   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca