
28 Mar
2006
28 Mar
'06
4:53 p.m.
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