gnupic: Any way to address the stack?


Previous by date: 8 Nov 2004 17:42:23 +0000 Re: PICs on Linux, Bart Oldeman
Next by date: 8 Nov 2004 17:42:23 +0000 Re: Any way to address the stack?, Robert J. Lee
Previous in thread: 8 Nov 2004 17:42:23 +0000 Re: Any way to address the stack?, Snail Instruments
Next in thread: 8 Nov 2004 17:42:23 +0000 Re: Any way to address the stack?, Robert J. Lee

Subject: Re: Any way to address the stack?
From: Byron A Jeff ####@####.####
Date: 8 Nov 2004 17:42:23 +0000
Message-Id: <20041108174216.GA2477@cleon.cc.gatech.edu>

On Mon, Nov 08, 2004 at 05:16:33PM +1300, David McNab wrote:
> Hi,
> 
> Is there any way to access the hardware return stack on PIC 16F873A?

No.

> 
> 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 ask, because I'm looking at ways of implementing a software 
> call/return stack, and thus eliminating the ceiling of 8 call levels.
> 
> As it is, a software call/return stack would be inefficient, because it 
> would require something like:
> 
>      movlw    low(return_address)
>      movwf    return_address_low
>      movlw    high(return_address)
>      goto     sw_stack_call
> return_address

That's the way to do it. There is no other way.

>      ...
> 
> This comes to 4 words per call, which will rapidly bloat out the 
> application.

You could shorten it into a jump table of fixed return locations. It may
shave an instruction or two off the call. Something like:

	movlw	0x43	; Index to return location #43
	goto	sw_stack_call
return_address_43:

Then use a jump table to jump back:
	movf	return_index,W
	addwf	PCL,F		; I'm presuming that PCLATCH is properly set.
	;... Jump return entries....
	goto	return_address_43 ; the 0x43 entry in the jump table.

Longer path but saves instructions on the call.

> 
> If there were a way to 'hack' the return stack, I could cut this to one 
> word per call.

Can't be done. Only the 18F parts have accessible return stacks. Deeper too 
IIRC.

> 
> Just asking, on the possibility that one of the 'unimplemented' FSRs (or 
> some other hack) might let me access the stack.

Nope. 

> 
> Thoughts?

Easy call. Can't be done. You'll have to find some other way to do it.

BAJ

Previous by date: 8 Nov 2004 17:42:23 +0000 Re: PICs on Linux, Bart Oldeman
Next by date: 8 Nov 2004 17:42:23 +0000 Re: Any way to address the stack?, Robert J. Lee
Previous in thread: 8 Nov 2004 17:42:23 +0000 Re: Any way to address the stack?, Snail Instruments
Next in thread: 8 Nov 2004 17:42:23 +0000 Re: Any way to address the stack?, Robert J. Lee


Powered by ezmlm-browse 0.20.