gnupic: Any way to address the stack?


Previous by date: 8 Nov 2004 22:01:04 +0000 Re: Any way to address the stack?, Byron A Jeff
Next by date: 8 Nov 2004 22:01:04 +0000 8 bit ethernet card, Ben Konrath
Previous in thread: 8 Nov 2004 22:01:04 +0000 Re: Any way to address the stack?, Byron A Jeff
Next in thread:

Subject: Re: Any way to address the stack?
From: "Robert J. Lee" ####@####.####
Date: 8 Nov 2004 22:01:04 +0000
Message-Id: <200411082201.06229.kiki@rjlee.dyndns.org>

On Monday 08 Nov 2004 07:41, Snail Instruments wrote:
> >Is there any way to access the hardware return stack on PIC 16F873A?
> >
> >In other words, to get the value of the current stack pointer, as well as
> >read (and possibly also write) the contents of the 8 stack levels
> > themselves?
>
> No.

I guess you could reverse-engineer how the chip works and then attach it to an 
electron-microscope pointing at the call stack's registers, but that's 
probably overkill.

> >I ask, because I'm looking at ways of implementing a software call/return
> >stack, and thus eliminating the ceiling of 8 call levels.
>
> Just a suggestion - if your application _really_ needs more then 8 levels
> of nested calls, use PIC18F442, pin compatible, but with 31 level stack.
> And software accessible on top of it.
>
> Josef
>
You can GOTO the procedure instead of calling it, storing a value in a 
register to indicate which call you used. Then instead of RETURN/RETLW, you 
can just jump back to the starting point using a lookup table:
 ; Load the call flag into W first
 ADDWF PCL,1
 GOTO callpoint1
 GOTO callpoint2
 GOTO callpoint3
 etc.

You may need to put your return value in a register rather than in W if you 
want RETLW-type behaviour

Using the indirection register, you can even create your own call stack. It's 
very register-hungry, but if you've got the free registers and you can afford 
the overhead then it does work.

Hope that helps,

— Robert J. Lee

Previous by date: 8 Nov 2004 22:01:04 +0000 Re: Any way to address the stack?, Byron A Jeff
Next by date: 8 Nov 2004 22:01:04 +0000 8 bit ethernet card, Ben Konrath
Previous in thread: 8 Nov 2004 22:01:04 +0000 Re: Any way to address the stack?, Byron A Jeff
Next in thread:


Powered by ezmlm-browse 0.20.