5NP4G
Embedded Processor Complex
7.3.1.4 Branch and Link Opcode
The branch and link opcode performs a conditional branch, adds one to the value of the current program
counter, and places it onto the program stack. Opcode fields Rt, h, and target16 determine the destination of
the branch. If Rt is in the range of 1 - 15, it is the word address of a GPR register, the contents of which are
used as the base of the branch destination. If Rt is 0, the base of the branch destination will be 0x‘0000’. The
h field indicates which half of the GPR register is used as the base address. An h = 0 indicates the even half
of the GPR register (high half of the GPR) and h = 1 indicates the odd half. The target16 field is added to the
base to form the complete branch destination. If the LinkPtr register indicates that the Branch and Link will
overflow the 16-entry program stack, a stack error occurs.
pseudocode:
IF (cond) THEN
-- put IA+1 onto the program stack
IF (LinkPtr=EndOfStack) THEN
StackErr <- 1
ELSE
ProgramStack(LinkPtr+1) <- PC + 1
END IF
-- load the IA with the branch target
IF (Rt=0) THEN
PC <- target16
ELSIF (h=0) THEN
PC <- GPR(Rt)(31:16) + target16
ELSE
PC <- GPR(Rt)(15:0) + target16
END IF
ELSE
nop
END IF
7.3.1.5 Return Opcode
The return opcode performs a conditional branch with the branch destination being the top of the program
stack. If the LinkPtr register indicates that the stack is empty, a stack error occurs.
pseudocode:
IF (cond) THEN
IF (LinkPtr=EmptyStack) THEN
StackErr <- 1
ELSE
PC <- ProgramStack(LinkPtr)
END IF
ELSE
nop
END IF
5NP4G Network Processor, Data Sheet, DS-0125-02
January 2006
Embedded Processor Complex
Page 205 of 607