Max Sedlusch
Max Sedlusch

Reputation: 105

how can I write the lr_usr register in supervisor mode with C inline assembly

I have searched for the specific question how to write banked registers in inline assembly but could not find an answer so my question seems novel. I want to write the lr_usr register in supervisor mode with an address of a function. so,

    uint32_t syscall_exit = (uint32_t) syscall_exit;
    uint32_t registers[14] = {97,6,7,6,7,6,7,6,7,6,7,5,7,(uint32_t) idle_thread_main};
    asm("ldr SPSR, #0x10");
    asm("msr lr_usr, %0":"=r"(syscall_exit)::"lr_usr");
    asm("ldmia &registers,{r0-r12,PC}^");

However, asm("msr lr_usr, %0":"=r"(syscall_exit)::"lr_usr"); throws an error: unknown register name 'lr_usr' in 'asm' I am unsure about the last command as well. The compiler does not say anything but I know this does not mean it is valid inline assembly. I want to load the contents of registers into r0-r12 and the last one, the function into the PC.

Upvotes: 1

Views: 54

Answers (0)

Related Questions