I am attempting to do something that seemed simple, but it is turning into a mess. I want to write a stack underflow monitor in main that both checks the stack pointer to insure it is at the bottom, and checks a byte under the stack bottom for a pattern (to better insure that the stack never went under when it was outside of main).
I've come to find that you cannot compile the following statement:
unsigned char * data StackPtr _at_ 0x81; (because it is an sfr address)
It seems like this should be the same thing as: sfr SP = 0x81; ..but with the added benefit of being able to dereference StackPtr to get at what it is pointing at.
The plan was to enter main at power-up, get the address SP is pointing at, stuff a pattern in there like 0xAA, then increment the SP. Later, when it returns to main, the test verfies the SP is still pointing at the SP++ address, and the original SP pattern is still 0xAA.
Assembler seems my only way out.