arm gcc swi call

OP #1786830
Rate this post
useful
not useful
Hello! I recently started using gcc-arm and I have a problem with swi. 
How to call a function with arguments? For example, my swi function:
"int sprintf (char * buf, const char * str, ...)" = swi 22

 Previously, I used IAR it was possible to do so:
# Pragma swi_number = 22
__swi __arm int sprintf (char * buf, const char * str, ...);

How it organized on gcc?
Moderator #1787618
Rate this post
useful
not useful
You may look into these codes:

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index_at91.html#at91_gamma

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/lpc2k_bundle_port/index.html

They are rather old and I did not check them with the latest versions of 
the GNU tools but they should at least give an idea.

Also browse through the newlib sources, there are implemantations of 
SWIs to implement semihosting.
OP #1792677
Rate this post
useful
not useful
why the params are not transferred in this case?

_inline_ void  sp(char*dest, char *cst, ...)

{

   asm volatile("swi 22");

}

and it works

void  sp(char*dest, char *cst, ...)

{

   asm volatile("swi 22");

}

In this case, the parameres are transmitted through the stack, but I do 
not need. When used inline it fits into the function.

How do I type this, an unspecified number of parameters?

_inline_ void sm(int i, int l)

{
   register int p0 asm("r0") = i;
   register int p1 asm("r1") = l;

   asm ("swi 0x148"::"r"(p0),"r"(p1));

}


_inline_ void sm(int i,...)

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now