4 sub-routines, User program configuration – Toshiba T2N User Manual

Page 159

Advertising
background image

2. User Program Configuration

146

PROSEC T2N

When it is necessary to execute repetitions of the same process in a
program, this process can be registered as a sub-routine. This sub-
routine can be executed by calling it (this is referred to as ‘sub-routine
calling’) at the required location. By this means, the number of program
steps can be reduced and, at the same time, the program becomes
easier to see since the functions have been put in order.

Sub-routines can be called from other program types (main program,
sub-program, interrupt program) and from other sub-routines (they can
also be called from the action part portion of SFC).

A sub-routine must be started by a SUBR instruction, and be ended by a
RET instruction.
A maximum of 256 sub-routines can be programmed.

It is necessary to assign a sub-routine number to the SUBR instruction
(sub-routine entry instruction). The limits of effective numbers are from 0
to 255.

SUBR (000)

Sub-routine number

The RET instruction (sub-routine return instruction) has no sub-routine
number.

2.3.4

Sub-Routines

Advertising