R
Chapter 3: PicoBlaze Instruction Set
ADD sX,01 ; increment register sX
SUB sX,01 ; decrement register sX
Figure 3-10: Incrementing and Decrementing a Register
If incrementing or decrementing a
inc_16:
;increment low byte ADD lo_byte,01
;increment high byte only if CARRY bit set when incrementing low byte ADDCY hi_byte,00
Figure 3-11: Incrementing a 16-bit Value
Negate
The PicoBlaze microcontroller does not have a dedicated instruction to negate a register value, taking the two’s complement. However, the instructions in Figure
Negate:
;invert all bits in the register performing a one’s complement XOR sX,FF
;add one to sX
ADD sX,01
RETURN
Figure 3-12: Destructive Negate (2’s Complement) Function Overwrites Original
Value
Another possible implementation that does not overwrite the value appears in Figure
Negate:
NAMEREG sY, value
NAMEREG sX, complement
;Clear ‘complement’ to zero LOAD complement, 00
;subtract value from 0 to create two’s complement SUB complement, value
RETURN
Figure 3-13: Non-destructive Negate Function Preserves Original Value
Multiplication
The PicoBlaze microcontroller core does not have a dedicated hardware multiplier. However, the PicoBlaze microcontroller performs multiplication using the available arithmetic and shift instructions. Figure
28 | www.xilinx.com | PicoBlaze |
|
| UG129 (v1.1.2) June 24, 2008 |