DVP-ES2/SA2/SS2/SA2/SX2/SE Operation Manual - Programming

3-48

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.
X0
X20
INC D0
Y0
CALL P10
X0 INC D1
Y1
FEND
INC D10
X2
P10
Y2
X2
X21 CALL P11
INC D11
Y3
SRET
INC D20
X2
P11
Y4
X22 CALL P12
X2 INC D21
Y5
SRET
X2
X23
X2
X2
X2
X24
X2
P13
P14
P12 INC D30
Y20
CALL P13
INC D31
Y21
SRET
INC D40
Y22
CALL P14
INC D41
Y23
SRET
INC D50
Y24
SRET
END
Main
Program
Subroutine
Subroutine
Subroutine
Subroutine
Subroutine