jumping out of subroutine with goto


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    Did you find this post helpful? Yes | No

    Default Re: jumping out of subroutine with goto

    Quote Originally Posted by helloo View Post
    Hey @ all,
    I wonder what happens within the µC when I write code that jumps out of a subroutine with the goto command?

    Example:

    Code:
    main:
       GOSUB label
    goto main
    
    label:
       GOTO somwhereelse
    RETURN
    
    somwhereelse:
       DOSOMETHING HERE
    GOTO main
    I know from other BASIC dialects that one should'nt do this, because it messes up the pointers. But what happens in PBP eg. the PIC itself?

    Is there a better solution for this problem?

    Greetings, helloo
    Or, you can try this,


    Code:
    main:
       GOSUB label
    goto main
    
    label:
       GOSUB somwhereelse
    RETURN
    
    somwhereelse:
       DOSOMETHING HERE
    RETURN
    
    Use GOSUB and RETURN instead of GOTO.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  2. #2
    Join Date
    Feb 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: jumping out of subroutine with goto

    Thanks for all. That is a solution to the problem. Thank you.

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