#74 ✓resolved
Peter Johnson

binding assembler functions with c++ function members

Reported by Peter Johnson | June 25th, 2011 @ 07:49 PM

Originally posted on Trac by loaf109@start.no
Original Trac Ticket

  Description

Hi

Ive yet to find an assembler that can bind/link a c++ function entry to an external function in an asm object or similar. What I want to do is to avoid using GCC's inline asm for my special optimized cases.

Im working on a modular sound system, so speed is important aswell as a good design.

At this moment I use nasm+gcc(g++) and link external asm functions as C functions. So the function members that are linked needs to be static. As of what Ive understood a static function member is exactly the same call convention as a C function. STDCALL.
What I want though is Thiscall convention, but as you guys probably are gonna reply to me, there are no real c++ function call standard. Each c++ compiler solves this differently. But it would be really nice to atleast have support for GCC thiscall convention :)

Trac Attachments

h3. Trac Comments
comment:1

              Changed 5 years ago by mu


What sort of support are you looking for from Yasm on this? If it's a matter of shuffling the arguments and stack around to implement any given calling convention, I don't think that's the place of the assembler to do. You can see the invoke macro which implements one C calling standard, and use it as a base to write one for whatever convention you need. My understanding is, regsiter vs. stack notwithstanding, the difference is that a this pointer is an implicit argument, and otherwise it's much like a C call.  http://www.angelcode.com/dev/callconv/callconv.html seems to be a good description of what various compilers use for various conventions (I just found that in a search).

comment:2

              Changed 5 years ago by mu


If you need to deal with mangled function names and linking against those, the easiest thing to do is probably to make sure the functinos you need are extern "C" so they don't get mangled; alternately we could add a way to express a mangled name that is otherwise not accepted by Yasm.  Raymon Chen's coverage of this for Microsoft compilers says thiscall is particularly confusingly mangled.

comment:3

              Changed 4 years ago by peter@tortall.net


This is best handling through the macro facility, not natively in the assembler itself, at least in NASM syntax.

      comment:3

                  Changed 4 years ago by peter@tortall.net

      Status
        changed from new to closed
    
      Resolution
        set to wontfix

This is best handling through the macro facility, not natively in the assembler itself, at least in NASM syntax.

      Status
        changed from new to closed
    
      Resolution
        set to wontfix

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Yasm Modular Assembler Project

Shared Ticket Bins

People watching this ticket

Pages