
Processing Data
R
Complement/Invert Register
The PicoBlaze microcontroller does not have a specific instruction to invert individual bits within register sX. However, the XOR sX,FF instruction performs the equivalent operation, as shown in Figure
T | If reading this document in Adobe Acrobat, |
| use the Select Text tool to select code snippets, |
| then copy and paste the text into your text editor. |
complement:
;XOR sX, FF invert all bits in register sX, same as one’s complement
LOAD s0, | AA | ; | load register | s0 | = | 10101010 |
XOR s0, | FF | ; | invert contents | s0 | = | 01010101 |
Figure 3-2: Complementing a Register Value
Invert or Toggle Bit
The PicoBlaze microcontroller does not have a specific instruction to invert or toggle an individual bit or bits within a specific register. However, the XOR instruction performs the equivalent operation. XORing register sX with a bit mask inverts or toggles specific bits, as shown in Figure
toggle_bit:
;XOR sX, <bit_mask>
XOR s0, 01 ; toggle the
Figure 3-3: Inverting an Individual Bit Location
Clear Register
The PicoBlaze microcontroller does not have a specific instruction to clear a specific register. However, the XOR sX,sX instruction performs the equivalent operation. XORing register sX with itself clears registers sX and sets the ZERO flag, as shown in Figure
XOR sX, sX ; clear register sX, set ZERO flag
Figure 3-4: Clearing a Register and Setting the ZERO Flag
The LOAD sX,00 instruction also clears register sX, but it does not affect the ZERO flag, as shown in Figure
LOAD sX,00 ; clear register sX, ZERO flag unaffected
Figure 3-5: Clearing a Register without Modifying the ZERO Flag
Set Bit
The PicoBlaze microcontroller does not have a specific instruction to set an individual bit or bits within a specific register. However, the OR instruction performs the equivalent
PicoBlaze | www.xilinx.com | 25 |
UG129 (v1.1.2) June 24, 2008