Hi!

Good idea. But it has some limitations one needs to keep in mind:

1) you cannot pass parameters this way, or you need to create a separate  
inline function for each case
2) you cannot rely on the normal calling conventions. The compiler will not 
recognize this as a function 
call and therefore will not assume R12..R15 clobbered and perhaps will do some 
optimizations that
are not expected.

However, if your assembly function preserves all registers, does not return 
anything and does not
take parameters, it will work perfectly.
If you want parameters or return values, you can extend the inline wrapper and 
tell the
compiler about clobbered registers, registers to put parameters in and where to 
put the result.

JMGross.


----- Ursprüngliche Nachricht -----
Von: Mathias K.
An: Peter Bigot
Gesendet am: 08 Sep 2011 19:30:18

Hello,

i have done a little workaround for this and it works like expected.


Regards,

Mathias

---------------

/* our external assembly function with reta return call */
__asm("\n\
.global _msp430x_asm_function  \n\
_msp430x_asm_function:         \n\
reta                           \n\
");

extern void _msp430x_asm_function(void * param);


/* our calla wrapper for all c functions */
static inline void msp430x_asm_function(void * param)
{
  __asm("calla #_msp430x_asm_function");
}


int main()
{
 void * param = 0x1234;

 msp430x_asm_function(param);

 while(1);

 return 0;
}


------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry® mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry® DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to