PDA

View Full Version : Help With stack (STKPTR)



rickypatel
- 15th February 2008, 00:29
im using the p18fx chips and im having a few problems

i have no idea how to use the stack ... i need to split the stack into three and then make my three routines see independent fragment of the stack.

any help is much appreciated....or links to tutorials

Thank you kindly

Darrel Taylor
- 15th February 2008, 01:02
There's usually no reason to manipulate the stack manually.

What are you trying to do with 3 stack segments?
<br>

rickypatel
- 15th February 2008, 01:23
well the task i have to complete requires me to use a stack..........we are getting to grips with how to use the pic and to use interrupts....so when a interrupt happens i wanna save the contexts of the WREG, STATUS and the BSR into each section of the stack. this is to be done with three different routines the ISR will run.......... i have done this by using MOVFF into registers but now i wanna use a stack

Thanks

Darrel Taylor
- 15th February 2008, 02:18
Very strange assignment.
Definitely not the way to do things.

I can say, the only part of the stack that's available to read/write is the TOS (Top Of Stack).

You can NOT split it in thirds and have 3 TOS's.

To do what you are suggesting, you would need to create your own stacks in software, and POP the entries off the hardware stack, then put them in your own stacks. Then in reverse order, to pop them off your stack.

But I really see no benefit, other than learning. And it's NOT beginners stuff.