R
Appendix : PicoBlaze Instruction Set and Event Reference
RETURN [Condition] — Return from Subroutine Call, Possibly with Conditions
The RETURN instruction is the complement to the CALL instruction. The RETURN instruction is also conditional. The new PC value is formed internally by incrementing the last value on the program address stack, ensuring that the program executes the instruction following the CALL instruction that called the subroutine. The RETURN instruction has no effect on the status of the flags.
The RETURN instruction has both conditional and unconditional variants. A conditional RETURN is only performed if a test performed against either the ZERO flag or CARRY flag is true. If unconditional or if the condition is true, the RETURN instruction pops the return address from the top of the CALL/RETURN stack into the PC. The popped value forces the program to return to the instruction immediately following the original subroutine CALL.
Ensure that a RETURN is only performed in response to a previous CALL instruction so that the CALL/RETURN stack contains a valid address.
The RETURN instruction does not affect the ZERO or CARRY flags. The flag values set prior to the RETURN instruction are maintained and available after the return from the subroutine call.
Condition
Depending on the specified condition, the program returns from a subroutine call. If the specified condition is not met, the program continues on to the next instruction.
Table C-4: RETURN Instruction Conditions
Condition |
| Description |
|
| |
<none> | Always true. Return from called subroutine unconditionally. | |
|
|
|
C | CARRY = 1. | Return from called subroutine if CARRY flag is set. |
|
|
|
NC | CARRY = 0. | Return from called subroutine if CARRY flag is cleared. |
|
| |
Z | ZERO = 1. Return from called subroutine if ZERO flag is set. | |
|
| |
NZ | ZERO = 0. Return from called subroutine if ZERO flag is cleared. | |
|
|
|
Pseudocode
if (Condition = TRUE) then
;pop the top of the CALL/RETURN stack into PC
;TOS = Top of Stack
PC Å TOS + 1; incremented value from Top of Stack else
PC Å PC + 1 endif
Registers/Flags Altered
Registers: PC, CALL/RETURN stack
Flags: Not affected
Notes
Do not use the RETURN instruction to return from an interrupt. Instead, use the RETURNI instruction.
106 | www.xilinx.com | PicoBlaze |
|
| UG129 (v1.1.2) June 24, 2008 |