Forum: ARM programming with GCC/GNU tools SWI.H and IAR

von Andy K. (montanaandy)

Rate this post
0 useful
not useful
I am attempting to port Martin's at91sam7_chanfat demo to run under IAR
in order that I might debug some hardware.  The problem is that SWI.H is
not syntactically correct for the IAR compiler.  The compiler gives up
trying to process function do_SWI, giving up on the lines starting with

  asm (
    "mov r0, %2 \n\t" \
    "mov r1, %3 \n\t" \
    "mov r2, %4 \n\t" \
    "mov r3, %5 \n\t" \
    "swi %a1    \n\t" \
    "mov %0, r0 \n\t" \
    :  "=r" (ret_val)
    :  "I" ((const int)swi_num),
      "r" (par0), "r" (par1), "r" (par2), "r" (par3)
    :  "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"

I was wondering if anybody has successfully ported either SWI.H to IAR,
or perhaps the project.



von Andy K. (horizonandy)

Rate this post
0 useful
not useful
I gave up on the port, per se.

Instead, I used the latest CHaN package (0.06) and his sample code,
integrating the FF.*, MMC.C and DISKIO.H files into the IAR BASIC
package.  That gave me the ability to debug the low-level operations
successfully on my hardware.  Turned out I had a third-party SPI device
that didn't de-assert MISO when it was not selected :(


von Clifford S. (clifford)

Rate this post
0 useful
not useful
Andy Kunz wrote:
>   asm (
>     "mov r0, %2 \n\t" \
>     "mov r1, %3 \n\t" \
>     "mov r2, %4 \n\t" \
>     "mov r3, %5 \n\t" \
>     "swi %a1    \n\t" \
>     "mov %0, r0 \n\t" \
>     :  "=r" (ret_val)
>     :  "I" ((const int)swi_num),
>       "r" (par0), "r" (par1), "r" (par2), "r" (par3)
>     :  "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"
>   );
It seems perhaps that you have solved/worked around this already,
however for future reference it may be worth noting that inline
assembler syntax is not standardised amongst C compilers and that GCC's
syntax is particularly arcane (albeit very powerful). You will probably
need to understand the inline asm syntax of both compilers to perform a
successful port. Information on GCC syntax is minimal; I have used
http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html in the
past - the examples are all in x86 assembler, but it is the syntax not
the instruction set that you are interested in.

Looking at the IAR manual (
http://www.iar.com/website1/ ) the syntax looks
broadly similar, however it does not appear to have the syntax to define
the interface between the asm and the C code that GCC has, or for
allowing the compiler to select registers rather than specifying them
specifically. Basically IAR is not as flexible or powerful in this
respect. I suspect that to port this it would be safer to use the full
IAR assembler and code it as a C callable function rather than inlining



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.