DVP-ES2/EX2/SS2/SA2/SX2/SE&TP Operation Manual - Programming 02 Explanations: SRET indicates the end of subroutine program. The subroutine will return to main program and begin execution with the instruction after the CALL instruction. Program example 1: When X0 = ON, the CALL instruction will jump to P2 and run the subroutine. With the execution of the SRET instruction, it will jump back to address 24 and continue the execution. Call subroutine P2 20 24 P2 Subroutine Subroutine return Program example 2: 1. When the rising-edge of X20 is triggered, CALL P10 instruction will transfer execution to subroutine P10. 2. When X21 is ON, execute CALL P11, jump to and run subroutine P11. 3.
When X22 is ON, execute CALL P12, jump to and run subroutine P12. 4. When X23 is ON, execute CALL P13, jump to and run subroutine P13. 5. When X24 is ON, execute CALL P14, jump to and run subroutine P14. When the SRET instruction is reached, jump back to the last P subroutine to finish the remaining instructions. 6. The execution of subroutines will go backwards to the subroutine of upper level until SRET instruction in P10 subroutine is executed. After this program execution will return to the main program.
3-46 Mnemonic Function Controllers SA2 ES2/EX2 SS2 SX2 SE SRET Subroutine Return Controllers SA2 ES2/EX2 SS2 SX2 SE OP Descriptions Program Steps N/A No contact to drive the instruction is required Automatically returns program execution to the address after CALL instruction in O100. SRET: 1 step PULSE 16-bit 32-bit ES2/EX2 SS2 SA2 SE SX2 SA2 ES2/EX2 SS2 SA2 SE SX2 ES2/EX2 SS2 SX2 SE X0 CALL X1 Y0 FEND M1 Y1 M2 Y2 SRET SRET CALL P2