3 PROGRAM ORGANIZATION UNITS
3.2 Functions (FUN)
17
3
Number of steps
To call a function, the number of steps is required not only for the program itself but also for the processing that passes the
argument and return value and the processing that calls the program.
■Program
The number of steps required for a function program is the total number of instruction steps plus a minimum of additional 13
steps occupied by the system. For the number of steps required for each instruction, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
■Calling source
When calling a function, the calling source generates the processing that passes the argument and return value before and
after the call processing.
• Passing the argument
The instruction used to pass the argument differs depending on the class and data type of the argument. The following table
summarizes the instructions that can be used to pass the argument.
• Calling the program
The following table lists the number of steps required to call the program of the function.
• Passing the return value
The instruction and the number of steps used for passing the return value are identical to those for passing the argument.
(1) Passing the argument
(2) Calling the FUN1 program
(3) Passing the return value
Argument class Data type Instruction used Number of steps
VAR_INPUT Bit LD+OUT
LD+MOVB
(Either of the instruction sets is used
depending on the combination of
programming language, function, and input
argument used.)
For the number of steps required for
each instruction, refer to the following.
MELSEC iQ-F FX5 Programming
Manual (Instructions, Standard
Functions/Function Blocks)
Word [unsigned]/bit string [16 bits]
Double word [unsigned]/bit string [32 bits]
Word [signed]
Double word [signed]
LD+MOV
LD+DMOV
Single-precision real number LD+EMOV
Time LD+DMOV
String (32) LD+$MOV
Array, Structure LD+BMOV
Item Number of steps
With EN 10
Without EN 12
Argument class Data type Instruction used Number of steps
VAR_OUTPUT Same as for passing the argument Same as for passing the argument Same as for passing the argument
(1)
(2)
(3)
FUN1
FUNCall FUN1
FUN2
MOV D0 XX
D0
M0
D10
M10
Y40
Y20
M0
Y20
Program file
FUN1 program
FUN file
The call-target program is
replaced with the instruction
for calling a function.
Program block 1
(displayed)
Calling the function