Xilinx UG129 Answering Machine User Manual


 
38 www.xilinx.com PicoBlaze 8-bit Embedded Microcontroller
UG129 (v1.1.2) June 24, 2008
Chapter 3: PicoBlaze Instruction Set
R
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 3-27. The CALL instruction is conditional and executes only
if the specified condition, listed in Table 3-6, is met. If the condition is false, then the
conditional CALL instruction has no effect other than requiring two clock cycles to execute.
No registers or flags are affected.
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 3-27.
The PicoBlaze microcontroller continues executing instructions in the subroutine call until
it encounters a RETURN instruction. See arrow ‘2’ in Figure 3-27.
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 3-6, is met. The RETURN instruction terminates the subroutine call, pops the top of
the CALL/RETURN stack, increments the value, and loads the value into the PC, which
returns the program flow to the instruction immediately following the original CALL
instruction. See arrow ‘3’ in Figure 3-27.
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
Figure 3-27: Example JUMP and CALL/RETURN Procedures
If CARRY is set, load the PC with the
address of the label skip_over.
Call my_subroutine. Save
the current PC to top of CALL/
RETURN stack. Load the PC with
the address of my_subroutine.
Return from my_subroutine.
Load the PC with the top of the CALL/
RETURN stack plus 1. Execute the
instruction immediately following
the associated CALL instruction.
ADDRESS 000
main:
ADD s0, s1
skip_over:
JUMP main
my_subroutine:
RETURN
2
3
1
A
JUMP C, skip_over
CALL my_subroutine
UG129_c3_06_051404