4 - Flags Register

You might also like

You are on page 1of 3

NAME DATE REMARKS Run DEBUG from the DOS prompt.

Type R and then press the Enter key to view


Onin John Paul P. 09-22-23 the registers and their contents. Your screen
Binuya should display the following:
COURSE/YEAR/SECTION INSTRUCTOR

BSCpE 3 Hilda
Wycoco The flags register shown above contains
Santos the following settings.

NV UP EI PL NZ NA PO NC

Experiment 04
The Flags Register The settings mean no overflow (NV), up
direction (UP), enable interrupt (EI), plus
sign (PL), nonzero (NZ), no auxiliary carry
I. Objective
(NA), parity odd (PO), and no carry (NC).

After performing this activity, you should CF (Carry Flag)


be able to
1. Discuss the behaviour of the flags and The carry flag is used to indicate that the
status register, and; result of an operation is too long to be stored
2. Identify operations that affect the in any of the registers.
flags and status registers.
PF (Parity Flag)

II. Introduction The parity flag is used to indicate that the


result of an operation contains an even
The flags register, also called status number or odd number of 1 bit.
register, is used to indicate the current status
of the machine and the results of execution. AF (Auxiliary Carry Flag)
Many instructions involving comparisons
and arithmetic operations change the status of The auxiliary carry flag is used to indicate
the flags. that the result of an operation contains a carry
over to the higher 4 bits.
A flag is a bit whose value (either 0 or 1)
is used to indicate a particular condition. A ZF (Zero Flag)
flag is set when the flag bit contains a 1, and
reset when the flag bit contains a 0. The zero flag is used to indicate that the
result of an operation is 0.
Eight of the 16 bits of the flags register SF (Sign Flag)
are common to all 8086-family processors.
The figure below shows the location of the The sign flag is used to indicate that the
flags in the flags register. result of an operation is negative.

OF DF IF TF SF ZF AF PF CF
IF (Interrupt Flag) 5. Use the R command to enter the value
0004 in register CX. Assemble the
The interrupt flag is used to enable and following instruction using the A
disable interrupts. command:

sub ax,cx
DF (Direction Flag)
Use the T command to single-step
The direction flag is used by string
through the above instruction. Write your
operations to determine the direction of data
observations on Table 1.
transfer.
6. Enter the value FFFF to register DX. Use
OF (Overflow Flag)
the A command to assemble the
instruction
The overflow flag is used with signed
numbers to indicate the result of an operation add bx, dx
contains a carry.
Try tracing through the instruction.
Usually, only 3 of the 8 flags are used: the Observe the flag registers. Write your
carry flag, the zero flag and the sign flag. In observations on Table 1.
the following exercises we will be dealing
with these three registers. Notice that the BX register contains 0000
when the result of the ADD instruction is
III. Procedures 10000. Because the register can only hold
2 bytes (four hexadecimal digits) the most
significant part is omitted.
1. Run debug from the DOS prompt.
Table 1
2. Type R and then press the Enter key to
view the registers and their contents. Note STEP CARRY ZERO SIGN
the flags register. Write the status of the 2 NC NZ PL
flags on Table 1. 5 NC ZR PL
6 CY ZR PL

3. Use the R command to enter the values


IV. Observation
0003 and 0001 in registers AX and BX,
respectively. After doing the procedures, I was able to
understand how different flag registers
4. Use the A command to assemble the behaved by implementing them in debug.
instruction: For example, the symbol CY (carry flag)
will be displayed if the result of an arithmetic
add ax,bx
operation like addition is too long to be stored
Try tracing through the instruction.
in any of the registers. NZ will be replaced by
Observe the flags register. Write the
ZR (zero flag), which tells us that the result
value of the flags on Table 1.
of the instruction we entered is 0. While the
sign flag can change from PL (positive) to
NG (negative) if the result is negative.
In addition, we can also observe in step 6
that even though we add the value of dx
(FFFF) to bx (0001) resulting in a value of
10000, the zero flag is displayed together
with the carry flag. This is due to the reason
that BX has a value of 0000 after tracing the
step because the register can only hold 2
bytes or four hexadecimal digits, which omits
the most significant part. However, with the
CY displayed, it indicates that the result is too
long to be stored.

V. Conclusion
Upon accomplishing the activity, I
learned the behavior and conditions of how
different flag resisters work, such as carry
flag, parity flag, auxiliary carry flag, zero
flag, sign flag, interrupt flag, direction flag,
and overflow flag.
Aside from that, I can now identify which
operations can affect the mentioned registers
and how they behave if certain conditions are
satisfied.

Documentation

You might also like