Hi
In order to make a stack checker in my Stellaris LM3S9D96 environment, I want to initialize the stack area with a specific pattern. The function used for that should take into account the actual position of the stack pointer, SP, and therefore I want to load a local variable with the SP. An often shown example of mixing C and Assembler looks the one below:
static int count_leading_zeros(uint32_t src)
{
int ret;
asm("CLZ ret, src");
return ret;
}
This indicates that local C variables can immediately be used within an __asm statement. However this does not work.
After a lot ot of searching around and a lot of unsuccessfull attempts my code look like this:
void HalInitStack(uint32_t ulPattern)
{
extern uint32_t ulStack;
__asm(" .bss _ulStack\n"
" .global _ulStack\n"
" mrs r0, MSP\n");
while ((uint32_t*)ulStack >= (uint32_t*)__stack) {
*((uint32_t*)ulStack--) = ulPattern;
}
}
The .bss statement could not be translated.
I would very much appreciate if anybody would provide me a hint that could solve the mystery.
Thanks in advance.
Br Kenneth