User`s guide
C for DSP56800E
User Stack Allocation
122
Targeting MC56F83xx/DSP5685x Controllers
In cases where the SP is modified by a run-time dependent amount, a warning is
issued.
Listing 6.1 Example 1 – Legal modification of SP Using Inline Assembly
#define EnterCritical() { asm(adda #2,SP);\
asm(move.l SR,X:(SP)+); \
asm(bfset #0x0300,SR); \
asm(nop); \
asm(nop);}
#define ExitCritical() { asm(deca.l SP);\
a sm(m o v e.l x : (SP) - , SR) ; \
asm(nop);\
asm(nop);}
#pragma check_inline_sp_effects on
int func()
{
int a=1, b=1, c;
EnterCritical();
C = a+b;
ExitCritical();
}
This case will work because there are no control flow merge points. SP is modified
consistently along all paths from the beginning to the end of the function and is
properly aligned.
Listing 6.2 Example 2 – Illegal Modification of SP using Inline Assembly
#define EnterCritical() { asm(adda #2,SP);\
asm(move.l SR,X:(SP)+); \
asm(bfset #0x0300,SR); \
asm(nop); \
asm(nop);}
#define ExitCritical() { asm(deca.l SP);\
a sm(m o v e.l x : (SP) - , SR) ; \