AREA StackSwitch, CODE, READONLY
stack_base DCD 0x28000
MOV r0, #0xf00d
MOV r0, #0
BL PrintHex ; TASK 1: Fix the program so that this prints 0xf00d
; ** by only making changes inside Mode_Switch
; and ensuring that you are still in process
; mode when you
; get here ** B Finish
MOV r0, #0x2 ; set stack to PSP
MSR CONTROL, r0 ; do it
ISB ; wait for it to be done
BX lr ; and return safely
; End your program
END ; Mark end of file
Hi, I'm currently learning how to use the ARM STM32F4 Discovery board and I've come across a problem I'm not sure how to solve. The code above doesn't actually do what is expected since we switch stacks and then POP r0 (from the wrong stack) which isn't what we want.
I cannot switch back to the stack like in MODE_SWITCH and I don't want to copy the value into a register before I make the switch to the other stack. How do I use MSR or MRS (presuming I am in privileged mode at this point) to get r0 from the other register so I can pop the correct value?
I've spent a while looking through the documentation and experimenting but I can't seem to get it work.