Справочник Пользователя для Mitsubishi Electronics FX2N

Скачать
Страница из 382
FX Series Programmable Controlers
Applied Instructions 5
5-7
5.1.2
CALL (FNC 01)
Points to note:
a) Many CALL statements can reference a single subroutine.
b) Each subroutine must have a unique pointer number. Subroutine pointers can be selected
from the range P0 to P62. Subroutine pointers and the pointers used for CJ (FNC 00)
instructions are NOT allowed to coincide.
c) Subroutines are not normally processed as they occur after an FEND instruction. When
they are called, care should be taken not to overrun the watchdog timer setting. For more
information on watchdog timers please see page 5-12.
d) Subroutines can be nested for 5 levels including
the initial CALL instruction. As an example the
program shown opposite shows a 2 level nest.
When X1 is activated the program calls subroutine
P11. Within this subroutine is a CALL to a second
subroutine P12. When both subroutines P11 and
P12 are active simultaneously, they are said to be
nested. Once subroutine P12 reaches its SRET
instruction it returns the program control to the
program step immediately following its original
CALL (see 
). P11 then completes its operation,
and once its SRET instruction is processed the
program returns once again to the step following
the CALL P11 statement (see 
).
Mnemonic
Function 
Operands
Program steps
D
CALL
FNC 01
(
C
all sub-
routine
)
Executes the 
subroutine 
program starting 
at the identified
 pointer position
Valid pointers from the range 0 to 62
Nest levels: 5 including the initial CALL
CALL, CALLP:
3 step
Subroutine pointer
P
PP
: 1 steps 
FX
0(S)
FX
0N
FX FX
(2C)
FX
2N(C)
FX
(2C)
FX
FX
2N(C)
FX
0N
FX
0(s)
PULSE-P
FX
(2C)
FX
FX
2N(C)
FX
0N
FX
0(s)
16 BIT OPERATION
FX
FX
0N
FX
0(s)
FX
(2C)
FX
2N(C)
32 BIT OPERATION
X0
P 10
CALL
FEND
SRET
P10
[ D ]
Subroutine D10
Operation:
When the CALL instruction is active it forces the
program to run the subroutine associated with the
called pointer (area identified as subroutine P10). A
CALL instruction must be used in conjunction with
FEND (FNC 06) and SRET (FNC 02) instructions. The
program jumps to the subroutine pointer (located after
an FEND instruction) and processes the contents until
an SRET instruction is encountered. This forces the
p r o g r a m   f l o w   b a c k   t o   t h e   l i n e   o f   l a d d e r   l o g i c
immediately following the original CALL instruction.
X1
P 11
CALL 
FEND
SRET
P11
P 12
CALL
SRET
P12
1
2