Inline assembly and ldm/stm
Marius Groeger
mgroeger@sysgo.com
Wed Apr 11 09:08:00 GMT 2007
Hi Bryce,
better late than never..
On Fri, 6 Apr 2007, Bryce Schober wrote:
> arm_2_registers_t result;
> __asm__ (
> "ldmia %0, {%1,%2} \n\t"
> : "+r" (src_addr_ptr), "=r" (result.reg[0]), "=r" ( result.reg[1])
> );
> return( result );
> }
>
> That seems to work fine until the compiler decides to use registers
> for %1 and %2 that aren't in ascending order. I've examined the
> assembly constraints and I don't see anything obvious.
I see two solutions to your problem:
1. you can directly specify two suitable registers in the assembler
part. You then also need to list those registers in the clobber list
argument of __asm__(). See the gcc info manual, Extended Asm for
the exact syntax.
2. you can use explicit register variables like this:
register int r1 asm("r1");
register int r2 asm("r2");
I actually don't know which would be preferable. The second one might be
nicer for long-term maintainance / portability as it is more obvious than
using __asm__'s clobber list.
Regards,
Marius
--
Marius Groeger <mgroeger@sysgo.com>
SYSGO AG Embedded and Real-Time Software
Voice: +49 6136 9948 0 FAX: +49 6136 9948 10
www.sysgo.com | www.elinos.com | www.osek.de | www.pikeos.com
Handelsregister: HRB Mainz 90 HRB 8066
Vorstand: Knut Degen, Robert Kaiser, Detlev Schaadt
Aufsichtsratsvorsitzender: Dr. Thomas Hoch
USt(VAT)-Id-Nr.: DE 149062328
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list