
R |
| Chapter 3: PicoBlaze Instruction Set |
|
| |
| ADDRESS 000 |
|
main: |
|
|
| JUMP C, skip_over | If CARRY is set, load the PC with the |
|
| address of the label skip_over. |
| A | Call my_subroutine. Save |
| CALL my_subroutine | |
| ADD s0, s1 | the current PC to top of CALL/ |
| RETURN stack. Load the PC with | |
| 3 | |
| the address of my_subroutine. | |
skip_over: | 1 |
|
| JUMP main |
|
my_subroutine: | 2 |
|
| Return from my_subroutine. | |
|
| |
|
| Load the PC with the top of the CALL/ |
| RETURN | RETURN stack plus 1. Execute the |
| instruction immediately following | |
|
| |
|
| the associated CALL instruction. |
|
| UG129_c3_06_051404 |
Figure 3-27: Example JUMP and CALL/RETURN Procedures
The JUMP instruction does not affect the ZERO and CARRY flags. All jumps are absolute; there are no relative jumps. Likewise, computed jumps are not supported.
See also “JUMP [Condition,] Address — Jump to Specified Address, Possibly with
Conditions,” page 101.
CALL/RETURN
The CALL instruction differs from the JUMP instruction in that program flow temporarily jumps to a subroutine function and then returns to the instruction following the CALL instruction, as shown in Figure
If the conditional CALL instruction is executed, then the current PC value is pushed on top of the CALL/RETURN stack. The address of the specified label, which is computed and assigned by the assembler, is loaded into the PC. The PicoBlaze microcontroller then executes the instruction at the specified label. See arrow ‘1’ in Figure
The PicoBlaze microcontroller continues executing instructions in the subroutine call until it encounters a RETURN instruction. See arrow ‘2’ in Figure
Every CALL instruction should have a corresponding RETURN instruction. The RETURN instruction is also conditional and executes only if the specified condition, listed in Table
If the conditional CALL instruction is executed, the ZERO and CARRY flags are potentially modified by the instructions within the called subroutine, but not directly by the CALL or
38 | www.xilinx.com | PicoBlaze |
UG129 (v1.1.2) June 24, 2008