the easiest solution would be to increment a variable before each gosub, and decrement before each return. Sending result to a LCD, RS232 or use an ICD to monitor it.
sure there's some other way...
the easiest solution would be to increment a variable before each gosub, and decrement before each return. Sending result to a LCD, RS232 or use an ICD to monitor it.
sure there's some other way...
Last edited by mister_e; - 18th February 2007 at 16:32.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Somehow, an interesting finding here for those using the MCS ICD.
When you hit 'ICD Compile and program' button (or CTRL+F10), it create a variable named DEBUG_STACK which hold the value/actual level of the stack.
NOW, to make things simple, just add those lines
And look what happen to your STACK_LEVEL variable in the ICD window while jumping here and there with gosubs.Code:@STACK_LEVEL = DEBUG_STACK STACK_LEVEL VAR BYTE EXT
i used that one...
Code:DEFINE LOADER_USED 1 DEFINE OSC 20 @STACK_LEVEL = DEBUG_STACK STACK_LEVEL VAR BYTE EXT START: PAUSE 1000 GOSUB LEVEL1 GOTO START LEVEL1: PAUSE 1000 gosub LEVEL2 RETURN LEVEL2: PAUSE 1000 GOSUB LEVEL3 RETURN LEVEL3: PAUSE 1000 gosub level4 RETURN LEVEL4: PAUSE 1000 RETURN
WOOOOHOOOO! Don't break my bubbleto me it's a nice finding... maybe usefull one day or another. Down side... it won't work unless you use the ICD... Darrel's stuff have a BIG advantage as you just need to read the StackPTR byte variable.
Last edited by mister_e; - 18th February 2007 at 17:56.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi Steve
I was wondering what is this ICD thing you talk about. Is it a part of Microchip MPASM suite or MCS electronics?
Anyhow, the latest update on my problem - I have it nailed. It wasnt the stack overflow after all. I had a case of data corruption in the event log. This particular case (case else) was not being handled leading to a program crash.
However, come to think of it, I appreciate your helping me and discovering something in the meanwhile. How nice would it be if the Melabs team could do something in the compiler/manual to show the stack nesting level of their inbuilt functions? I think the documentation should mention this as it is a very important aspect when using Pics with 4 level stack.
Jerson
I refered to the Mecanique ICD which come with MicroCode Studio Plus...
short tutorial on Bruce's website.
http://rentron.com/PicBasic/MCS_X3.htm
The full Version of MicroCode Studio really worth it's price. I really love the Bootloader. I don't often use the ICD, but found something interesting with this thread.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks