Tool/software:
Hi experts,
Could you please help providing couple lines of example that read the core registers into a variable? for example the SP register.
Thanks,
Hang.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hi experts,
Could you please help providing couple lines of example that read the core registers into a variable? for example the SP register.
Thanks,
Hang.
Hi Hang,
See below example. The SP is loaded with the content at address pointed by R0. The R0 is later loaded with the value at address APP_START_ADDRESS + 4.
;; ;; Load the stack pointer from the application's vector table. ;;movw r0, #(APP_START_ADDRESS & 0xffff)movt r0, #(APP_START_ADDRESS >> 16) ldr sp, [r0]
;; ;; Load the initial PC from the application's vector table and branch to ;; the application's entry point. ;; ldr r0, [r0, #4] bx r0
You can embed assembly code inside C code like below example.
asm(" ldr sp, [r0]);