Hi all, I am cracking my head to see why Keil's uVision2 has this problem? Calling a subroutine callee on the first time, returned to the original Caller with no problem. Calling it 2nd time and follows, caused a critical fault of NOT returning to original caller's address SP_max: 032 I have a mixture of C & Assembly coding. where Timer interrupts happen under C and most logical functions are done under .A51s. What could be the cause of calling a subroutine which doesn't return to the original caller's address? Please advise. Head scratching, James
Dear all, Thanks for all the kind advice. Very useful. found the problem cause. In fact, it is really the stack overflowing into my own data registers which caused the wrongly returned address. Well... I didn't know that 8051's stack 'eats' down from 00 of RAM instead of 'eating' upwards like MOT's. For Microchip, there is a separate set of memory for stacks??? That's what I remember. Thanks again guys! Cheers, James
"Well... I didn't know that 8051's stack 'eats' down from 00 of RAM instead of 'eating' upwards like MOT's." The stack grows up from wherever you set the stack pointer. When it passes 0xff it wraps to zero and overwrites the register banks. Stefan
"For Microchip, there is a separate set of memory for stacks???" No matter how you implement the stack, you will have problems if it overflows!