If the aforementioned check passes, you can also write a magic value word x bytes below the stack (say 100H), and on program termination check if it hasn't changed. That way you will get an early warning if your stack grows large.
(By the way, for C maybe 100H is too little an amount, since it uses the stack so much. Would have to try it and see.)
Is this supposed to give me the current adress of the Stack ?
unsigned int ReadSP(void)
{
__asm
ld HL,#0
add HL,SP
__endasm;
} SDCC seems to handle int return from functions via HL - so yes, with SDCC compiler it should work fine
로그인(등록) 해서 댓글을 씀
