Other Parts Discussed in Thread: TMS570LS0432
Hi everyone, I am trying to make multi scheduler and to do that I have to write assembly code so that I can load and store the value of the register to save and restore the context of tasks. However, when I try to run the program, it always return to the dabort function (Run memory test). My question is : is there any things that I have to configuring before writing a assembly code, My code is followed this manual :
tinyos.rockfishnw.com/_downloads/Part_2-Context_switching.pdf
When I debuged this line "ldmfd r2!, {r3-r5} " makes the program return to dabort function. The board I am using is TMS570LS0432 HDK
Here is my code:
.text
.arm
.ref currentSP
.global switch_to_current
currentSPconst .word currentSP
.def SwitchToCurrent
.asmfunc
SwitchToCurrent
ldr r0, currentSPconst
ldr sp, [r0]
ldmfd sp!, {r0}
msr spsr_cxsf, r0
ldmfd sp!, {r0-r12, lr, pc}^
.endasmfunc
.def SaveOS
.asmfunc
SaveOS
sub lr, lr, #4
stmfd sp!, {r0-r2}
mrs r0, spsr
mov r1, lr
mov r2, sp
add sp, sp, #(3 * 4)
msr cpsr_c, #(0xC0 | 0x13)
stmfd sp!, {r1}
stmfd sp!, {lr}
stmfd sp!, {r3-r12}
ldmfd r2!, {r3-r5}
stmfd sp!, {r3-r5}
stmfd sp!, {r0}
ldr r0, currentSPconst
str sp, [r0]
.endasmfunc
.def RestoreOS
.asmfunc
RestoreOS
ldr r0, currentSPconst
ldr sp, [r0]
ldmfd sp!, {r0}
msr spsr_cxsf, r0
ldmfd sp!, {r0-r12, lr, pc}^
.endasmfunc