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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.