# Branch if carry generated
Overflow Detection (signed operands):
An overflow is detected when two positives are added and
the sum is negative, or when two negatives are added and
the sum is positive. The overflow condition can control a
conditional branch, as shown in the following code:
addi rB, rA, IMM16
xor rC, rB, rA
xorhi rD, rB, IMM16
and rC, rC, rD
blt rC, r0,label
# The original add operation
# Compare signs of sum and rA
# Compare signs of sum and IMM16
# Combine comparisons
# Branch if overflow occurred
Exceptions
None
Instruction Type
I
Instruction Fields
A
= Register index of operand rA
B
= Register index of operand rB
IMM16
= 16-bit signed immediate value
Bit Fields
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
A
B
IMM16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
IMM16
0x04
8.5.3. and
Instruction
bitwise logical and
Operation
rC ← rA & rB
Assembler Syntax
and rC, rA, rB
Example
and r6, r7, r8
Description
Calculates the bitwise logical AND of rA and rB and stores
the result in rC.
Exceptions
None
Instruction Type
R
Instruction Fields
A
= Register index of operand rA
B
= Register index of operand rB
C
= Register index of operand rC
8. Instruction Set Reference
NII-PRG | 2018.04.18
Nios II Processor Reference Guide
176