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 mass is attached to a spring that hangs vertically. The extension produced in the spring is 6 cm on Earth. The acceleration due to gravity on the surface of the Moon is one-sixth of its value on the surface of the Earth. The extension of the spring on the Moon would be:

  3. Directions: Each item in this section consists of a sentence with an underlined word followed by four words (a), (b), (c), and (d). Select the option that is opposite in meaning to the underlined word and mark your response in your Answer Sheet accordingly.

    The deluge affected the population.
  4. The major source of vitamins and minerals for vegetarians is

  5. Which of the following statements about the Deccan Riots Commission is/are correct?

    1. The Commission did not hold enquiries in the districts which were not affected.

    2. The Commission did record the statements of ryots, sahukars and eye-witnesses.

    Select the correct answer using the code given below:

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