Table 52.
Shift and Rotate Instructions
Instruction
Description
rol
ror
roli
The
rol
and
roli
instructions provide left bit-rotation.
roli
uses an immediate value to specify the number of
bits to rotate. The
ror
instructions provides right bit-rotation.
There is no immediate version of
ror
, because
roli
can be used to implement the equivalent operation.
sll
slli
sra
srl
srai
srli
These shift instructions implement the
<<
and
>>
operators of the C programming language. The
sll
,
slli
,
srl
,
srli
instructions provide left and right logical bit-shifting operations, inserting zeros. The
sra
and
srai
instructions provide arithmetic right bit-shifting, duplicating the sign bit in the most significant bit.
slli
,
srli
and
srai
use an immediate value to specify the number of bits to shift.
3.9.6. Program Control Instructions
The Nios II architecture supports the unconditional jump, branch, and call instructions.
These instructions do not have delay slots.
Table 53.
Unconditional Jump and Call Instructions
Instruction
Description
call
This instruction calls a subroutine using an immediate value as the subroutine's absolute address, and stores the
return address in register
ra
.
callr
This instruction calls a subroutine at the absolute address contained in a register, and stores the return address in
register
ra
. This instruction serves the roll of dereferencing a C function pointer.
ret
The
ret
instruction is used to return from subroutines called by
call
or
callr
.
ret
loads and executes the
instruction specified by the address in register
ra
.
jmp
The
jmp
instruction jumps to an absolute address contained in a register.
jmp
is used to implement switch
statements of the C programming language.
jmpi
The
jmpi
instruction jumps to an absolute address using an immediate value to determine the absolute address.
br
This instruction branches relative to the current instruction. A signed immediate value gives the offset of the next
instruction to execute.
The conditional branch instructions compare register values directly, and branch if the
expression is true. The conditional branches support the following equality and
relational comparisons of the C programming language:
•
== and !=
•
< and <= (signed and unsigned)
•
> and >= (signed and unsigned)
The conditional branch instructions do not have delay slots.
Table 54.
Conditional Branch Instructions
Instruction
Description
bge
bgeu
bgt
bgtu
ble
bleu
blt
These instructions provide relative branches that compare two register values and branch if the
expression is true. Refer to the "Comparison Instructions" section of this chapter for a description of
the relational operations implemented.
3. Programming Model
NII-PRG | 2018.04.18
Nios II Processor Reference Guide
103