SWI.H and IAR

OP #1174462
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.

Thanks.

Andy
#1174463
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 :(

Andy
#1174464
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/1.0.1.0/78/1/index.php ) 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
it.

Clifford

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

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.