The subroutine call instruction, labeled as FNC01, allows the program to jump to a specific label and execute a block of code. It supports operands ranging from P0 to P127 and requires three program steps. On the other hand, the subroutine return instruction, FNC02, is used to exit the subroutine and return control to the next instruction following the CALL command. This instruction does not require any operands and only takes one program step.
As illustrated in Figure 1, when X0 is activated, the program jumps to the label P10 and begins executing the subroutine. Once the SRET instruction is encountered, the program returns to the point immediately after the original CALL instruction, resuming normal execution flow.
Figure 1: Subroutine Call and Return Instruction Usage
When using subroutine call and return instructions, it's important to follow some key guidelines:
1. Ensure that the labels used for subroutines are unique and do not conflict with those used in jump instructions.
2. Subroutines can be nested, allowing up to five levels of nesting, which helps in organizing complex programs into modular sections.
These instructions are essential in creating structured and efficient programs, especially in industrial automation and embedded systems where reusability and maintainability are crucial.
Silicone rubble cold shrinkable tube
Dongguan Zhonghe Electronics Co., Ltd. , https://www.zhonghesleeving.com