Does CLEAR Command clear return adrress of a subroutine?


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Default Does CLEAR Command clear return adrress of a subroutine?

    Hi there,

    Does CLEAR command clear the return address of a subroutine on the stack ?


    Thanks.

    ===============================
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    No - the stack space is not part of the data space. Just your defined variables and PBP (internal) defined variables are cleared.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Thanks Paul.

    Other then hard reset, how do I clear return adresses?
    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.

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    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
    __________________

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    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).
    I'd almost bet money that there's an undocumented instruction that handles POP's on the 14 bit types...but you'd figure somebody would've found it by now.

Similar Threads

  1. 8x8 keypad matrix...
    By mbox in forum General
    Replies: 5
    Last Post: - 9th October 2014, 18:43
  2. Multiple RETURNS within a single subroutine
    By BrianT in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st June 2009, 16:43
  3. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 20:36
  4. Replies: 14
    Last Post: - 26th September 2007, 05:41
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts