All Exams Test series for 1 year @ ₹349 only
Question

In 8085 microprocessor which of the following flag(s) is (are) affected by an arithmetic operation ?

The correct answer is

AC, CY, Z flags

Understanding 8085 Flags and Arithmetic Operations

The 8085 microprocessor has a special 8-bit register called the Flag Register. This register consists of several individual flip-flops, each representing a specific condition that arises after an arithmetic or logic operation. These flags help in making decisions and controlling the flow of the program.

8085 Flag Register Structure

The 8085 flag register bits are arranged as follows:

| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |

| S | Z | X | AC | X | P | X | CY |

(X indicates an undefined bit)

The important flags affected by operations are:

  • Sign Flag (S): Set if the most significant bit (D7) of the result is 1 (indicating a negative number in 2's complement).
  • Zero Flag (Z): Set if the result of the operation is 0.
  • Auxiliary Carry Flag (AC): Set if there is a carry out from bit D3 to bit D4 during an arithmetic operation. This is primarily used in BCD (Binary Coded Decimal) arithmetic.
  • Parity Flag (P): Set if the result has an even number of 1s (even parity).
  • Carry Flag (CY): Set if there is a carry out from bit D7 or a borrow into bit D7 during an arithmetic operation.

Impact of Arithmetic Operations on 8085 Flags

Arithmetic operations in the 8085, such as addition (ADD, ADC), subtraction (SUB, SBB), increment (INR), and decrement (DCR), typically affect the flags based on the result of the operation. Most standard arithmetic operations affect all five flags: S, Z, AC, P, and CY.

Let's consider an example:

Suppose the accumulator contains value 10H (0001 0000 binary) and we perform ADD 05H (0000 0101 binary).

Calculation: 0001 0000 + 0000 0101 = 0001 0101 (which is 15H)

  • S Flag: D7 is 0, so S is reset (0).
  • Z Flag: Result is 15H (not 0), so Z is reset (0).
  • AC Flag: No carry from D3 to D4 (0001+0000 = 0001), so AC is reset (0).
  • P Flag: Result 0001 0101 has two 1s (even parity), so P is set (1).
  • CY Flag: No carry out from D7, so CY is reset (0).

In this specific example, S, Z, AC, and CY are reset, while P is set. This demonstrates that arithmetic operations update these flags according to the result.

Another example: Accumulator = FFH (1111 1111), ADD 01H (0000 0001)

Calculation: 1111 1111 + 0000 0001 = 0000 0000 with a carry out.

  • S Flag: D7 of the result is 0, so S is reset (0).
  • Z Flag: Result is 00H, so Z is set (1).
  • AC Flag: Carry from D3 to D4 (1111 + 0000 - considering D3 > D4 part results in 1+0=1, no carry, but let's look at the carry between the nibbles. D3 is 1, D4 is 1. For 1111+0001, looking at the lower nibble 1111+0001: 1+1=0 carry 1 to D1, 1+1=0 carry 1 to D2, 1+1=0 carry 1 to D3. So, from D3 to D4, there is a carry. AC is set (1).
  • P Flag: Result 00H has zero 1s (even parity), so P is set (1).
  • CY Flag: Carry out from D7, so CY is set (1).

In this example, Z, AC, P, and CY are set, while S is reset. Again, multiple flags are affected.

While instructions like INR and DCR affect S, Z, AC, and P flags, they do not affect the CY flag. However, the question asks about "an arithmetic operation" in general, and standard operations like ADD, SUB affect all five flags. The options provided include a subset of these flags.

Analyzing the Options

Let's evaluate the given options based on which flags are affected by arithmetic operations:

  • Option 1: AC flag Only - Incorrect, other flags like Z and CY are also affected.
  • Option 2: CY flag Only - Incorrect, other flags like AC and Z are also affected.
  • Option 3: Z flag Only - Incorrect, other flags like AC and CY are also affected.
  • Option 4: AC, CY, Z flags - This option lists three flags that are indeed affected by typical 8085 arithmetic operations (like ADD, SUB). Although S and P flags are also affected, this option correctly identifies flags that are changed based on the arithmetic result. Among the given choices, this option lists the most comprehensive set of affected flags.

Therefore, based on the common behavior of 8085 arithmetic instructions, the AC, CY, and Z flags are all affected.

8085 Flags Affected by Arithmetic Operations
Flag Affected by Arithmetic? Condition for Set
Sign (S) Yes Result MSB (D7) is 1
Zero (Z) Yes Result is 00H
Auxiliary Carry (AC) Yes Carry from D3 to D4
Parity (P) Yes (usually) Result has even parity
Carry (CY) Yes Carry out from D7 or borrow into D7

The question asks which flag(s) is (are) affected. Since AC, CY, and Z are all affected by arithmetic operations, option 4 is the correct choice among the given possibilities.

Revision Table: 8085 Flag Register

Summary of 8085 Flags
Flag Position (Bit) Purpose
Sign (S) D7 Indicates the sign of the result.
Zero (Z) D6 Indicates if the result is zero.
Auxiliary Carry (AC) D4 Used for BCD operations.
Parity (P) D2 Indicates if the result has even parity.
Carry (CY) D0 Indicates a carry or borrow.

Additional Information on 8085 Operations and Flags

Different types of operations in the 8085 affect the flags in different ways:

  • Arithmetic Operations (ADD, SUB, INR, DCR, etc.): Generally affect S, Z, AC, P, CY (except INR/DCR don't affect CY).
  • Logic Operations (AND, OR, XOR, NOT, etc.): Typically affect S, Z, P. They usually reset AC and CY flags (e.g., AND, OR, XOR reset AC, CY).
  • Data Transfer Operations (MOV, MVI, LXI, etc.): These operations do not affect any flags.
  • Branch Instructions (JMP, CALL, RET, etc.): These instructions check the status of flags but do not change them.
  • Stack Operations (PUSH, POP): Do not affect any flags.

Understanding which instructions affect which flags is crucial for writing correct 8085 assembly programs, especially when dealing with conditional jumps or checking results of calculations.

Was this answer helpful?

Important Questions from Miscellaneous

  1. A stone is thrown horizontally from the top of a 20 m high building with a speed of 12 m/s. It hits the ground at a distance R from the building. Taking g = 10 m/s2 and neglecting air resistance will give :

  2. A sphere of volume V is made of a material with lower density than water. While on Earth, it floats on water with its volume f1V (f1 < 1) submerged. On the other hand, on a spaceship accelerating with acceleration a < g (g is the acceleration due to gravity on Earth) in outer space, its submerged volume in water is f2V. Then:

  3. A railway wagon (open at the top) of mass M1 is moving with speed v1 along a straight track. As a result of rain, after some time it gets partially filled with water so that the mass of the wagon becomes M2 and speed becomes v2. Taking the rain to be falling vertically and the water stationery inside the wagon, the relation between the two speeds v1 and v2 is :

  4. Consider the following statements:

    1. Distance between the longitudes becomes zero on North Pole and South Pole.

    2. Distance between the longitudes is maximum on the Equator.

    3. Number of longitudes is more than number of latitudes.

    Which of the statements given above is/are correct?

  5. One block of 2⋅0 kg mass is placed on top of another block of 3⋅0 kg mass. The coefficient of static friction between the two blocks is 0⋅2. The bottom block is pulled with a horizontal force F such that both the blocks move together without slipping. Taking acceleration due to gravity as 10 m/s2, the maximum value of the frictional force is :

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App