EmbDev.net

Forum: ARM programming with GCC/GNU tools arm gcc swi call


Author: Vova7890 Vova (vova7890)
Posted on:

Rate this post
0 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?

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
You may look into these codes:

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...

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.

Author: Vova7890 Vova (vova7890)
Posted on:

Rate this post
0 useful
not useful
Thanks, I already thought of myself today :)

Author: Vova7890 Vova (vova7890)
Posted on:

Rate this post
0 useful
not useful
but this method is why it failed to function on 8 arguments, such as the 
transfer goes through the stack, but normally does not work. Maybe 
someone knows a working method? There must be some interface for a swi 
in gcc ...

Author: Vova7890 Vova (vova7890)
Posted on:

Rate this post
0 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

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.