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 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

38

www.xilinx.com

PicoBlaze 8-bit Embedded Microcontroller

UG129 (v1.1.2) June 24, 2008

Page 38
Image 38
Xilinx UG129 manual Call/Return