I have the following statement:
asm volatile("ldr r0, =0x10000");
Instead of writing 0x10000 I want to write a parameter so it will look like this:
uint32_t addr = 0x20000;
asm volatile("ldr r0, =addr");
how can I manage to do it?
i am using ARM processor.
I want to do this:
At the end I want to do this:
asm volatile("ldr r0, =0x10000");
asm volatile("ldr r0, [r0]");
asm volatile("mov sp, r0");
same for pc
thanks.
gcc is quite capable of generating those instructions so you can do:
void** p = 0x10000;
register void* sp asm("sp") = *p;
__asm__ __volatile__("" : : "r" (sp) : "memory");
Note it's dangerous to mess with sp
so make sure you know what you are doing.
To load pc
you will indeed need to use a mov
such as:
void** p = 0x10000;
__asm__ __volatile__("mov pc, %0" : : "r" (*p) : "memory");
__builtin_unreachable();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.