Thanks Paul.
Other then hard reset, how do I clear return adresses?
Thanks Paul.
Other then hard reset, how do I clear return adresses?
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
I haven't tried it myself...but...
Looking thru the datasheet for the 18F4620, I see:
TOSU, TOSH, TOSL (top of stack, upper, high, low) and the STKPTR register. Looks like the contents of STKPTR are Read/Write. So, in theory, you should be able to decrement the value in the low 5 bits of STKPTR and thereby 'POP' the last 'PUSH' off the stack.
SAYZER,
On 16 bit devices (e.g., 18F), you can reset the STKPTR = 0 to "clear" all the addresses on the stack. The values really are not cleared - but the stack pointer points to the first location (0) and does not know about the "old" values. You could actually clear them if you wanted as Ski noted but the pointer tells the PIC where to place and get stack data.
On 14 or lesser bit devices (e.g., 16F or lesser), you cannot clear the Stack (it is a circular buffer and does not reside in program or data space).
NOTE: you must be very careful messing with the Stack because behind the scenes, PBP uses it!
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi, Sayzer
I didn't look at it very closely ...
but I feel you can find your solution Here :
http://www.pbpgroup.com/modules/wfse...p?articleid=14
and once more ...
Thanks to Whom ????
D.A.R.R.E.L. !!!! ..........
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Darrel's clever method for the 16F type PICs creates a software stack - the real "stack" is not in program or data space and cannot be accessed (unless there is a back door that nobody knows about as Ski suggested)
I guess that SAYZER could create a software stack (as Alain is suggesting) and then manipulate it as needed? SAYZER, what are you trying to do and with what family of PIC?
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi, Paul
There's also something Doable ( depends on use ...) :
A GOSUB loads an address you can choose in the stack ...
if ending the SUB with a GOTO instead of a RETURN ... This address will stay as the new "return", "retfie" ... address.
That's used with the "RESUME Label" of PbP ...
I do not think "clearing" the stack would be really useful ... as a stack containing zeros will cause the device to reset ONLY its program on the first "return or so" met ...
Alain
Last edited by Acetronics2; - 9th February 2008 at 17:12.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks