Does CLEAR Command clear return adrress of a subroutine?


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Ok, here is a simple example good enough to explain the issue.
    ...........
    If you're careful, and I mean very, very careful, you could turn off the Stack Overflow/Underflow reset bits in the CONFIG and just not worry about the RETURN addresses...let them overflow as they will.
    But again, you'd have to be very careful, especially if you nest any GOSUB's at all...so that might not work out at all.
    Maybe take DT's Software Gosub example shown earlier and add your own subroutine to POP the last GOSUB address off the Software Stack.

    Actually, I just looked at the code for the first time...
    In the swStack.inc file, you could use this section:

    Code:
    '------------Pop Address from the Stack---------------------------------------
    Pop:
        if StackPTR = 0 then  StackEmpty = 1  ; Update Empty status
        if StackEmpty = 0 then                ; If Stack isn't Empty
           Address = Stack[StackPTR-1]        ; Get last Address from the Stack
           StackPTR = StackPTR - 1            ; Point to Prior Stack level
           StackFull = 0                      ; 0 - Since we just removed 1
        else
           STunderflow = 1                    ; Stack was Empty on swReturn
        endif
        if StackPTR = 0 then  StackEmpty = 1  ; Update Empty status
    return
    You have access to the Pop subroutine.

    But I'm guessing here...since I haven't used to swGosub/swReturn routines at all.........

    You 'include' DT's software stack routines, your code above becomes:
    Code:
    Begin:
    OK = 0
    MainMenu:
    '...stuff is going on here...
        IF OK = 1 THEN
                   @ swGOSUB PrintMemory
        ENDIF
        GOTO MainMenu
    PrintMemory:
        IF Memory = 0 THEN
                   Gosub Pop  'regular Gosub here, generic, can be used system wide
                   Goto BEGIN    'no more return address from the Gosub above
        ENDIF
        swRETURN
    Again, I'm guessing...
    Last edited by skimask; - 19th February 2008 at 17:33.

Similar Threads

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

Members who have read this thread : 1

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