Tool/software: TI C/C++ Compiler
Hi all,
I am trying to solve this issue relating to the use of assembly code in a C program with code composer studio. The code compile well but in debugging, the execution generates a fault (certainly incorrect instruction ode). For instance the following will generate faults:
__asm(" STMFD R0!, {R4}");
__asm(
//Recall the values the R4-R11 and SP_process stored in the state buffer
" LDMIA R0!,{R4-R11,R12}\n\t" //Store Values
" MSR PSP, R12\n\t" //Move contents of R1 to PSP
//Return from restore task using process stack
);
Hence the function below will also generate a fault.
void createTask(unsigned *buf, char *stack, task_t task_start, task_t taskFinish)
{
// This line stores space for register R4-R11 and SP into
// threads[currThread].savedregs, which is the buffer to hold the state
// of the processor which is not saved automatically during a function
// boundary. The series of instruction stores a zero value for each of the
// registers except SP which is the value of the input pointer stack
__asm(" MOV R4, #0");
__asm(" STMFD R0!, {R4}"); //R4
__asm(" STMFD R0!, {R4}"); //R5
__asm(" STMFD R0!, {R4}"); //R6
__asm(" STMFD R0!, {R4}"); //R7
__asm(" STMFD R0!, {R4}"); //R8
__asm(" STMFD R0!, {R4}"); //R9
__asm(" STMFD R0!, {R4}"); //R10
__asm(" STMFD R0!, {R4}"); //R11
// Put space for all of the register onto the process stack
// for when the task returns (calls yeild). Space for registers
// R0-R3, R12, ReturnAddress (taskFinish), and xPSR.
__asm(" MOV R5, R2"); // getting the address of task_start
__asm(" MOV R6, R3"); // getting the address of taskFinish
__asm(" MOV R3, #0x1000000"); //Change R3 to xPSR value
__asm(" STMFD R1!, {R3}"); //xPSR
__asm(" STMFD R1!, {R5}"); //Return Address
__asm(" STMFD R1!, {R6}"); //R14
__asm(" STMFD R1!, {R4}"); //R12
__asm(" STMFD R1!, {R4}"); //R3
__asm(" STMFD R1!, {R4}"); //R2
__asm(" STMFD R1!, {R4}"); //R1
__asm(" STMFD R1!, {R4}"); //R0
//Store R1 into the SP spot in the savedregs buffer
__asm(" STMFD R0!, {R1}");
__asm(" MOV R4, #0");
__asm(" STMFD R0!, {R5}"); //R5
__asm(" STMFD R0!, {R6}"); //R6
*/
}
Is there anything settings or coding principles to follow? I have followed the recommendations made in
ARM Optimizing C/C++ Compiler
v17.3.0.STS
User's Guide.
Thanks for helping.