CALL and RETURN Instructions
The CALL instruction interrupts the flow of a program by passing control to an internal or external
subroutine. An internal subroutine is part of the calling program. An external subroutine is another
program. The RETURN instruction returns control from a subroutine back to the calling program and
optionally returns a value. For more detailed information on the CALL and RETURN instructions, see
sections “CALL” on page 135 and “RETURN” on page 161.
When calling an internal subroutine, CALL passes control to a label specified after the CALL keyword.
When the subroutine ends with the RETURN instruction, the instructions following CALL are processed.
instruction(s)
EXIT
sub1:
instruction(s)
RETURN
instruction(s)
CALL sub1
When calling an external subroutine, CALL passes control to the program name that is specified after the
CALL keyword. When the external subroutine completes, you can use the RETURN instruction to return to
where you left off in the calling program.
instruction(s)
…
…
...
sub2:
instruction(s)
RETURN
instruction(s)
CALL sub2
MAIN
For more information about calling subroutines, see Chapter 6, “Writing Subroutines and Functions,” on
page 57.
Control Flow within a Program
Chapter 4. Controlling the Flow within a program 49