Sunteți pe pagina 1din 3

I.

Introduction
The STATUS register is important in programming the PIC, it contains the arithmetic
status of the ALU (Arithmetic Logic Unit), the RESET status and the bank select bit for data
memory. As with any register, the STATUS register can be the destination for any instruction.
If the STATUS register is the destination for an instruction that affects the Z, DC or C bits,
then the write to these three bits is disabled. These bits are set or cleared according to device
logic.

The Carry bit (C) watches if a carry-out from the MSB bit occurs. The Digit Carry bit
(DC) watches if a carry out from the 4 th lower order of the byte is occurred. And the Zero bit
(Z) watches if the result of an arithmetic or logic operation was zero.

II.

Objectives of the Experiment


To understand the behavior of STATUS register flags: zero (Z), carry (C), and digit

III.

carry (DC).
To observe the contents of STATUS flags when an arithmetic operation is performed.

Results
Part 2: Observing the contents of STATUS flags
Table 3.1: Result of STATUS Flags in the Data Movements Operation
Operation

DC

WREG

movlw .2

0001 1000

movwf x

0000 0000

movlw .7

0000 0010

movwf y

0000 0111

Table 3.2: Result of STATUS Flags in the Add Operation


Operation
Clearflags
movf x,w
addwf y,w
movwf z

Z
1
0
0
0

DC
1
0
0
0

C
1
0
0
0

WREG
0000 0111
0001 1000
0000 0010
0001 1010

Table 3.3: Result of STATUS Flags in the Subtraction Operation_1


Operation
clearflags
movf x,w
subwf y,w
movwf z

Z
0
0
0
0

DC
0
0
0
1

C
0
0
0
1

WREG
0001 1010
0001 1010
0000 0010
0001 0110

Table 3.4: Result of STATUS Flags in the Subtraction Operation_2


Operation
clearflags
movlw .6
sublw .4
movwf z

Z
0
0
0
0

DC
1
0
0
0

C
1
0
0
0

WREG
0001 0110
0001 1000
0000 0110
1111 1110

Part 4: Exercises
Table 3.5: STATUS Flags Exercises
OPERATION
A + B (Hex)
B 2 (Hex)
5 4 (Hex)
A + B 2 (Hex)
110 111 (Binary)

Z
0
0
0
0
0

DC
1
1
1
1
0

C
0
1
1
1
0

IV.

Discussion
. By running the given source code in MPLAB IDE, we focused our attention to the
bottom line of MPLAB IDE, it is noticed that for some operation the small letters c, dc, and z
changed to capital letters C, DC, and Z. The change in the letters correspond to a change in
the content of the STATUS register flags. For example, if the c becomes C it means that
the Carry flag has an input of 1. The WREG status was also observed in the simulation by
clicking the watch tool. It is also important to clear the STATUS flag before performing an
arithmetic or bit-wise operation so the previous operation would not affect the new one .For
experiment 3, through MPLAB IDE simulation, the behavior of the STATUS register flags
was observed. STATUS register monitors and controls the status of arithmetic and bitwise
operation.

V.

Conclusion
The behavior of STATUS register flags may change depending on the results of the
arithmetic or bitwise operations. The Zero Flag (Z) becomes set when the result of an
operation is zero. The Digit Carry Flag (DC) becomes set if the binary of 0 comes no carryout from 4th lower order of the byte occurred and the binary 1 comes a carry-out from the 4 th
lower order of the byte occurred. While the Carry Flag (C) becomes set when the result of an
operation is greater than 255 (0x0ff).

S-ar putea să vă placă și