Programming style - GOTO or GOSUB ?


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Brussels, Belgium
    Posts
    104


    Did you find this post helpful? Yes | No

    Default

    Thanks for the answer. I used to use GOSUBs for pretty much everything but now I keep it for oft visited chunks and use GOTOs to navigate a more linear path. I think I tripped myself up once by going down to many .SUBs and lost the way home

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    18Fs using PBP have a 27 level stack. That is a lot of GOSUBs.

    Whatever you do - keep track of your GOSUBs. Don't ever GOSUB to a routine and then use
    GOTO to get "back".

    Every time you GOSUB, you put an address on the stack. Every time you RETURN, you pop that address and resume execution there. If you push addresses there without pop-ing them off, you will eventually get a stack overflow which causes a processor reset.
    Charles Linquist

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default

    If you have functions or routines used often in your program, then gosub is a must.

    It helps keep the program structured and by carefully placing the subroutine in a complete page of pogram memory, the overall program can be reduced in size very much.

    It would be nice to see local variables sometime in the next updates of PBP,but even without this, GOSUBs are my preference.

    Other languages like C "push" the programmer to use functions or subroutines.

    Ioannis

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