omron — Unconditional Branch Instructions

Unconditional Branch Instructions Unconditional Branch Instructions There are three unconditional branching instructions in eV+: l GOTO l CALL l CALLS GOTO The GOTO instruction causes program execution to branch immediately to a program label instruction somewhere else in the program. The syntax for GOTO is: GOTO label label is an integer entered at the beginning of a line of program code. label is not the same as the program step numbers: Step numbers are assigned by the system; labels are entered by the programmer as the opening to a line of code. In the next code example, the numbers in the first column are program step numbers. The numbers in the second column are program labels. 61 .

62 GOTO 100 63 . 64 . 65 100 TYPE "The instruction GOTO 100 got me he re." 66 . A GOTO instruction can branch to a label before or after the GOTO instruction. GOTO instructions can make program logic difficult to follow and debug, especially in a long, complicated program with many subroutine calls. Use GOTO instructions with care. A common use of GOTO is as an exit routine or exit on error instruction. CALL The CALL and CALLS instructions are used in eV+ to implement subroutine calls. The CALL instruction causes program execution to be suspended and execution of a new program to begin.

When the new program has completed execution, execution of the original program resumes at the instruction after the CALL instruction. The details of subroutine creation, execution, and parameter passing are covered in Subroutines on page 28. The simplified syntax for a CALL instruction is: CALL program(arg_list) program is the name of the program to be called. The program name must be specified exactly, and the program being CALLed must be resident in system memory. eV+Language User's Guide, v2.x, 18318-000 Rev A Page 60