In my CW11.1 project, i have many codes like below:
static void ASIL_ALU_XOR_Test(void)
{
asm ("stwu sp,-0x020(sp)");
/* Save registers*/
asm ("stw r28,0x04(sp)");
asm ("stw r29,0x08(sp)");
so when i compile the code it will report the warning like below, whether this will influence the function, if yes, how should i modify?
Description Resource Path Location Type
inline asm instruction 'STWU', defines reserved register r1. Mixing assembler and C code depends on the inline assembler not modifying the reserved registers directly. Use function level assembler if you need to directly modify the reserved registers. ASIL_ALU_Check.c /S2LS/Sources line 484 C/C++ Problem
Hi,
I don't think it is necessary to manually store these registers on stack.
The compiler will do that automatically. You can disassemble the function to see that all used nonvolatile registers (given by EABI standard) are stored automatically.
Simple example:
This is translated as:
Used r0 and r8 are volatile registers, it's not necessary to keep them. So, the stack frame is even not created here.
Now let's add this - explicitly touch r29:
As you can see, r29, r30 and r31 are now put on stack:
So, it doesn't make sense to do that manually again.
Regards,
Lukas