Exiting a subroutine without using return?

Status
Not open for further replies.

How about:
Code:
movf   RUNSEQ, w
iorwf   RUNSEQ2, w
 
:idea:

Another method of goto'ing (does that sound right??) from a subroutine is to use a flag...... ok an example is in order.....


MAIN
CALL GET_RS232 ;CALL OUR RS232 SUB

BTFSC FLAG,NO_RS232 ;DID WE GET ANY RS232?
GOTO RS232_BAD ;NO, SO GO AND DEAL WITH IT

..... REST OF MAIN


GET_RS232
BCF FLAG,NO_RS232 ;CLEAR NO_RS232 FLAG

.............. CODE TO CHECK FOR RS232
.............. IF NONE, THEN SET THE FLAG

RETURN



ok, so it's not strictly a "goto" from a subroutine, but you get the idea, this method can be usefull, for example, if we are sitting in a subroutine that wait for 1 sec, but we want to detect a switch to end the subroutine...... we can set a flag for the switch then return......

Hope this helps :wink:
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…