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

    So should there be any difference in the amount of memory used when coding ? Empirically they seem to use the same amount of compiled memory.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    GOSUB will use just a little more space.

    Example...
    I am working a piece of code with two sub routines that when finished will be part of the main code, a flow through thing. I have them as GOSUBs now for testing, easily comment out a GOSUB to test one or the other.

    As the code stands currently with the GOSUBs and RETURNs in place 3528 bytes are used.
    When I remove the GOSUBs and RETURNs 3516 bytes are used.

    The extra space is small compared to having a "function" written over and over.
    The way to have the smallest code is this respect is to have one loop, but if you have an ADC that needs read more than once in the main loop a GOSUB/RETURN will be much smaller than having the ADC written twice... or more.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 2

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