Mitsubishi Electronics FX2C Home Theater Server User Manual


 
FX Series Programmable Controlers Applied Instructions 5
5-7
5.1.2 CALL (FNC 01)
Points to note:
a) Man
y
CALL statements can reference a sin
g
le subroutine.
b) Each subroutine must have a unique pointer number. Subroutine pointers can be selected
from the ran
g
e P0 to P62. Subroutine pointers and the pointers used for CJ (FNC 00)
instructions are NOT allowed to coincide.
c) Subroutines are not normall
y
processed as the
y
occur after an FEND instruction. When
the
y
are called, care should be taken not to overrun the watchdo
g
timer settin
g
. For more
information on watchdo
g
timers please see pa
g
e 5-12.
d) Subroutines can be nested for 5 levels includin
g
the initial CALL instruction. As an example the
pro
g
ram shown opposite shows a 2 level nest.
When X1 is activated the pro
g
ram calls subroutine
P11. Within this subroutine is a CALL to a second
subroutine P12. When both subroutines P11 and
P12 are active simultaneousl
y
, the
y
are said to be
nested. Once subroutine P12 reaches its SRET
instruction it returns the pro
g
ram control to the
pro
g
ram step immediatel
y
followin
g
its ori
g
inal
CALL (see
). P11 then completes its operation,
and once its SRET instruction is processed the
pro
g
ram returns once a
g
ain to the step followin
g
the CALL P11 statement (
see
).
Mnemonic Function
Operands
Program steps
D
CALL
FNC 01
(
C
all sub-
routine
)
Executes the
subroutine
pro
g
ram startin
g
at the identified
pointer position
Valid pointers from the ran
g
e 0 to 62
Nest levels: 5 includin
g
the initial CALL
CALL, CALLP:
3 step
Subroutine pointer
P
PP
: 1 steps
X0
P 10CALL
FEND
SRET
P10
[ D ]
Subroutine D10
Operation:
When the CALL instruction is active it forces the
pro
g
ram to run the subroutine associated with the
called pointer (area identified as subroutine P10). A
CALL instruction must be used in con
j
unction with
FEND (FNC 06) and SRET (FNC 02) instructions. The
pro
g
ram
j
umps to the subroutine pointer (located after
an FEND instruction) and processes the contents until
an SRET instruction is encountered. This forces the
pro
g
ram flow back to the line of ladder lo
g
ic
immediatel
y
followin
g
the ori
g
inal CALL instruction.
X1
P 11CALL
FEND
SRET
P11
P 12CALL
SRET
P12
1
2