AW: [U-Boot-Users] Re: combined C/ARM assembly example

Jonas Mark (ST-FIR/ENG1) * Mark.Jonas at de.bosch.com
Tue Mar 28 16:53:21 CEST 2006


Hello Shakthi,

>   unsigned long *ptr1, *ptr2;
> 
>   /* not here */
> 
>   asm volatile ("ldr r0,= 0x30800000");
>   asm volatile ("ldr r3,= 0x30800004");
>   asm volatile ("ldr r1,= 0xff000000");
>   asm volatile ("movs r2, r1, lsl #1");
>   asm volatile ("mrs r1, cpsr");
>   asm volatile ("str r1, [r0, #0]");
>   asm volatile ("str r2, [r3, #0]");
> 
>   /* placed here */
> 
>   ptr1 = (unsigned long *) (0x30800000);
>   ptr2 = (unsigned long *) (0x30800004);

What you are facing is called "register clobbering". See
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC93 and look for
the keyword "clobber".

At first the behavior of GCC's inline assembler might look evil but once
you understood its power you are going to love it.

Best Regards,
Mark




More information about the U-Boot mailing list