When booting up a toy kernel, I use this code to switch to user mode:
mrs r1, CPSR @ Switch to System mode
orr r1, r1, #0xc
msr CPSR, r1
ldr sp, =gUsrStackBase @ Setup USR stack (shared with System mode)
mov r1, #0x10 @ Get user-mode CPSR into SPSR
msr SPSR, r1
movs pc, r0 @ Switch to USR mode and branch
But following the movs
instruction, instead of the user-mode CPSR value I set, (0x10), there's random garbage in the CPSR. Why could this be?