Searching \ for '[SX] Reading the stack' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/devices.htm?key=sx
Search entire site for: 'Reading the stack'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Reading the stack'
2005\11\01@061318 by dog8spamn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dog8spam wrote:

Is there a way to read the top of the stack so a subroutine can know where it was called from?  I would prefer this over setting some bits in my mishmash variable (slower, makes uglier code).
Thanks
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@062509 by peterverkaikn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

Unfortunately no.

Inside the isr it is possible using the secret instruction popPC.

For normal calls, you could pass the return address to the subroutine, then use pushPC and reti to jump back to that address.

regards peter
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94159
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@062517 by Coriolisn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote:

Not possible, I too would like this functionality but it doesn't exist, you can however access the shadow stacks for variables saved before entering the ISR via the secret instructions. I fathomed a way of creating your own substack but cannot recall exactly how (I never implemented it, its one of the forth interpretor's unfinished aspects), you can create your own shadow stack by pushing the address on a personally created stack. I have stack code you can have (www.sxlist.com has a copy of it).

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94160
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@063125 by Coriolisn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote:

Peter, pushPC is only used for calling the ISR correct? If you disable interrupts, pushPC, call sub, (in sub) popPC, enable interrupts, could you not mimic this ability? The last two steps would need to be done immeadiatly in the subroutine because it wouldn't work for more than one level of subroutine.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94162
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@064103 by peterverkaikn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

pushPC is also used by debug, so if you use that you can not use the debugger. The shadow stack is only 2 levels deep.

(isr and debug, or isr and your use)
regards peter
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94164
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@070558 by Coriolisn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote:

I neglected to incorporate debug, because I generally assume debug won't be used when using the secret instructions. But that brings up another question, if you take care on not stepping through (or "break"ing in) the critical section (between disabling and reenabling interrupts), could you use the debugger for the program?

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94169
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@072632 by peterverkaikn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

See this thread
http://forums.parallax.com/forums/default.aspx?f=7&m=80504&g=80543#m80543
regards peter
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94175
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@074342 by dog8spamn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dog8spam wrote:

From the aforementioned thread;

MOV W,JMPLOC ;Load W with "Next" Addr on this 1/2 Page2

If I am reading this correctly this will load w with the next address.  If "next address" means the top of the stack or where the next ret will return to, that code will do exacly what I need.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94180
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@080435 by peterverkaikn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

Here's another thread
http://forums.parallax.com/forums/default.aspx?f=7&m=56795&g=57650#m57650
regards peter
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94187
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@082947 by dog8spamn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dog8spam wrote:

From reading that I think this is getting way to complex and it probably would be best to stick with my origional code.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94194
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@091104 by peterverkaikn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

You could do this

from location 1 mov m,#($+4)>>8 mov w,#adr1 call @mySub adr1:   ;ret adr for this call

from location 2 mov m,#($+4)>>8 mov w,#adr2 call @mySub adr2:   ;ret adr for this call

mySub:

;save m and w for reference or store to private stack or whatever
;do some code retp  ;return to adr1 or adr2, specified by m and w

regards peter
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94216
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@094233 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hi All;
I'd like to pipe in here as I have some experience at this.

The 8 level CALL STACK is totally independent of the 2 level SHADOW STACKS, and the CALL STACK is not accessible under program control in any manner that I have been able to determine.

As Peter V indicates, the desired action could be simulated by saving a return address prior to jumping to (calling) the subroutine, and then returning from the subroutine via pushing the saved return address on the M:W registers and forcing the return jump via the RETI instruction.

There is caution to be used here as there are also hidden STATUS bits that get effected on executing a RETI.

Paul;
Your description is not correct; pushPC loads M:W into the PCshadow, and popPC does the reverse. It takes a RETI to trigger the jump, but of course all other shadows are then also popped, thereby changing the whole state of the processor.

As an answer to Armored Cars' original post, my recommendation for the casual programmer is to just use the standard call/return instructions if at all possible. The other approaches, while possible as in the RTOS I have written, are quite involved.

Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94228
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@100846 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

[Quoting: "Peter Verkaik"]
You could do this

from location 1 mov m,#($+4)>>8 mov w,#adr1 call @mySub adr1:   ;ret adr for this call

from location 2 mov m,#($+4)>>8 mov w,#adr2 call @mySub adr2:   ;ret adr for this call

mySub:

;save m and w for reference or store to private stack or whatever
;do some code retp  ;return to adr1 or adr2, specified by m and w

regards peter

Hi Peter;
While your suggestion is technically correct, I believe the your last line (retp ;return to adr1 or adr2, specified by m and w) may lead the reader to believe that the return is directed by the contents of M and W, rather than the entry at the top of the call stack.
The contents of M and W are totally irrelevant to return, you had simply chosen them as a convenient location to save the return address so that the subroutine code could use it if required.
Also, would loading M and W also not be written somewhat more simply as:

Location1      code                             ;arbitrary code
                  code                             ;arbitrary code
                  mov    m,#Return1>>8     ;get the upper 4 return address bits into m (must go through w for SX48/52)
                  mov    w,#Return1          ;get the lower 8 return address bits into w
                  call     Subroutine            ;go to the routine
Return1         code                             ;arbitrary code
                  code                             ;arbitrary code

Subroutine     code                             ;arbitrary code
                  code                             ;arbitrary code
                  retp

Cheers,
Peter (pjv)


---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94238
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@104055 by peterverkaikn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

pjv,
Yes, that would rule out possible errors due to counting storage words.

And yes, the example only shows how to pass the value that is on top of stack (after call Subroutine), to be used in the subroutine, without changing the call/return scheme.

regards peter
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94247
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@105230 by Coriolisn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote:

I think there was a little misunderstanding about my suggestion (no biggie), I wasn't suggesting forcing the system as you do in your MTOS Peter (pjv), but using pushPC and popPC as a temporary store to pass the address onto the subroutine, though now looking more at it, there would be a built in offset error since the PC pushed onto the shadow PC stack would not be the address of the call instruction.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94249
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@110852 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hi Paul;
Sorry to keep harping on this, but I understood your suggestion (pushPC) to literally mean that you expected the PC itself to be pushed onto the shadow stack, and this of course is not how it works; pushPC pushes M:W onto the PCshadow.

And the converse, popPC pops the PCshadow into M:W.

It is the RETI instruction that pops the PCshadow into the PC; and, as previously noted, all other shadows (W, FSR,STATUS), into their respective registers.

Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94253
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\11\01@113426 by Coriolisn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote:

*smacks himself* Ok nevermind, It'd work if you setup M:W like for IREAD, but thats just making the situation more complicated.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94260
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...