Is a 'GOTO' Or a 'GoSub'?


Closed Thread
Results 1 to 2 of 2
  1. #1

    Default Is a 'GOTO' Or a 'GoSub'?

    If I have a statement like below:
    Code:
    I2C_Routine:
    			I2CWRITE SDA,SCL,$36,[Loc], Fail
    Return
    The jump to the label Fail is executed as a Goto or a GoSub instruction at the end of the above statement in case I2C fails?

    I am trying to avoid stack errors, my code does a 'GoSub I2C_Routine', I will have a stack left un'RETURN'ed in case the fail is executed as a goto. What should I do in this case? I don't think I can put a return at the end of the Fail function in case it is a goto jump. I hope I made my question clear.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Is a 'GOTO' Or a 'GoSub'?

    It is a GOTO.

    But you can put a RETURN after the Fail routine.
    It will return to the same point that called the I2C_Routine.
    DT

Similar Threads

  1. Problem with GOSUB/GOTO and Newhaven OLED question
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th April 2013, 11:24
  2. Programming style - GOTO or GOSUB ?
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th December 2010, 19:08
  3. timeout of Hserin, goto, gosub or both?
    By flipper_md in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th October 2009, 19:43
  4. If ... Then Gosub <> If ... Then Goto?
    By oldtoddler in forum General
    Replies: 6
    Last Post: - 27th February 2006, 12:52
  5. Goto inside a gosub??? Problems...
    By leonel in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 13th October 2005, 13:17

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