Processing Data
R
ADD16:
NAMEREG s0, a_lsb ; rename register s0 as “a_lsb”
NAMEREG s1, a_msb ; rename register s1 as “a_msb”
NAMEREG s2, b_lsb ; rename register s2 as “b_lsb”
NAMEREG s3, b_msb ; rename register s3 as “b_lsb”
ADD a_lsb, b_lsb ; add LSBs, keep result in a_lsb
ADDCY a_msb, b_msb ; add MSBs, keep result in a_msb
RETURN
Figure 3-8: 16-Bit Addition Using ADD and ADDCY Instructions
See also:
•“ADD sX, Operand
•“ADDCY sX, Operand
SUB and SUBCY Subtract Instructions
The PicoBlaze microcontroller provides two subtract instructions, SUB and SUBCY, that compute the difference of two
The SUBCY instruction is a subtract operation with borrow. If the CARRY flag is set, then SUBCY subtracts an additional one from the resulting difference.
The SUBCY instruction is commonly used in
SUB16:
NAMEREG s0, a_lsb ; rename register s0 as “a_lsb”
NAMEREG s1, a_msb ; rename register s1 as “a_msb”
NAMEREG s2, b_lsb ; rename register s2 as “b_lsb”
NAMEREG s3, b_msb ; rename register s3 as “b_lsb”
SUB a_lsb, b_lsb | ; | subtract | LSBs, | keep | result | in | a_lsb |
SUBCY a_msb, b_msb | ; | subtract | MSBs, | keep | result | in | a_msb |
RETURN |
|
|
|
|
|
|
|
Figure 3-9: 16-Bit Subtraction Using SUB and SUBCY Instructions
See also:
•“SUB sX, Operand
•“SUBCY sX, Operand
Increment/Decrement
The PicoBlaze microcontroller does not have a dedicated increment or decrement instruction. However, adding or subtracting one using the ADD or SUB instructions provides the equivalent operation, as shown in Figure
PicoBlaze | www.xilinx.com | 27 |
UG129 (v1.1.2) June 24, 2008