1. Example of subroutine call
1. Example of subroutine call
Below is a simple example of calling a subroutine using its parameters and local variables.
1.1. Example
Below is a simple example of calling a subroutine using its parameters and local variables.
1.2. Case study explanation
Implement a program that adds two single characters and returns a double character result.
The subroutine 'addition' implements this logic.
图1 Subroutine parameter filling
1.3. Logic realise
Implement an input bit parameter as an execution enable.
Implement two input single character parameters as operands for addition.
Implement a dual word parameter output as the result.
图2 logic realise
1.4. External call
The ladder diagram below implements the call logic.
When M0=ON, D2=D0+D1. When M10=ON, D12=D10+D11.
图3 External call
The parameters for two CALL instructions are filled in as follows.
图4 Parameter filling for the first CALL instruction
图5 Parameter filling for the second CALL instruction