Stack over flow with IF THEN RETURN ENDIF???


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2007
    Posts
    2

    Default Stack over flow with IF THEN RETURN ENDIF???

    I was wondering, when I use an IF THEN statement am I allowed to use a return within the statement? Im just not sure how PBP structures an IF THEN in assembly and I am affraid if I use a return statement within an IF THEN it will cause some kind of stack over flow. EXAMPLE:

    MAIN:
    GOSUB FLAG:
    GOTO MAIN:


    FLAG:
    IF FLAG0 = 0 THEN
    C0ON = C0MAIN
    FLAG0 = 1
    RETURN
    ENDIF


    Thanks for the help and info

  2. #2
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default I do it.

    Hello kdoske, welcome to the forum. This is an awsome place for help.

    As far as your question, I do it in my programs without any problems. I'm quite sure it's OK to do however in your snippett I believe you should have a RETURN after the ENDIF incase your IF FLAG0 = 0 THEN statement doesn't execute, unless there's more after the ENDIF you didn't show.

    Hope this helps.
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  3. #3
    Join Date
    Dec 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Wow, thanks so much for the quick reply. I am new to pic basic and I am loving how easy it is. It doesn't take place of all assembly language but its a great tool. So far I am really impressed with its ease of use.

    Oh no, there is much more involved in the program. I just copy and pasted that little bit. Once again thanks so much for the info.

    Kdoske

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    ENDIF is more a compiler directive to tell where the IF-THEN statement block finish. I don't see any problem using it like that... but it might be caused by the Sunday's lack of sleep
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 06:28
  2. Making a menu
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 36
    Last Post: - 12th November 2008, 19:54
  3. Help needed with Select Case?
    By jessey in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd January 2008, 00:12
  4. Software Stack
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th December 2007, 10:04
  5. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11

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