Processing Data

R

Register sY Literal kk

Register sX

7 6 5 4 3 2 1 0

 

7

 

 

6

 

 

5

 

 

4

 

 

3

 

 

2

 

 

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

Bitwise AND

If all bit results are zero, set ZERO flag.

ZERO

UG129_c3_03_051404

Figure 3-22:The TEST Instruction Affects the ZERO Flag

Each bit of register sX is logically ANDed with either the contents of register sY or a literal constant, kk. The operation sets the ZERO flag if the result of all bitwise AND operations is zero.

If the second operand contains a single ‘1’ bit, then the CARRY flag tests if the corresponding bit in register sX is ‘1’ as shown in the example in Figure 3-23.

LOAD s0,

05

;

s0

= 00000101

TEST s0,

04

;

mask

=

00000100

 

 

; CARRY

=

1, ZERO = 0

 

 

 

 

 

 

Figure 3-23:Generate Parity for a Register Using the TEST Instruction

In a broader application, the CARRY bit generates the odd parity for the included bits in register sX, as shown in Figure 3-24. The second operand acts as a mask. If a bit in the second operand is ‘0’, then the corresponding bit in register sX is not included in the generated parity value. If a bit in the second operand is ‘1’, then the corresponding bit in register sX is included in the final parity value.

Register sY

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7

 

 

 

 

6

 

 

 

 

5

 

 

 

4

 

 

 

3

 

 

 

 

2

 

 

 

 

1

 

 

 

 

0

 

Literal kk

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Register sX

 

 

 

7

 

 

 

 

6

 

 

 

 

5

 

 

 

 

4

 

 

 

3

 

 

 

2

 

 

 

 

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Mask out unwanted bits. 0=mask bit, 1=include bit

0

Generate odd parity (XOR) from bit results.

CARRY

UG129_c3_04_051404

Figure 3-24:The TEST Instruction Affects the CARRY Flag

PicoBlaze 8-bit Embedded Microcontroller

www.xilinx.com

33

UG129 (v1.1.2) June 24, 2008

Page 33
Image 33
Xilinx UG129 manual 22The Test Instruction Affects the Zero Flag