The Status Flags | Digital Electronics - Electrical Engineering (EE) PDF Download

The Status Flags

The Flag flip-flops are special outputs from the adder circuit. They consist of four separate D type flip-flops, each of which can be set to 1 or cleared to 0. They are set or cleared by the result in the adder. They signal, or ‘flag’ to the user, that a particular event has occurred.

The Carry flag (C)

The carry flag will be set if the result of any arithmetic or logic event causes a logic 1 to be carried over from bit 7 into the ‘carry bit’, (which is the carry flag). The carry flag can be cleared at any time by making the ‘clear carry’ input (~CLC) logic 0.

The Overflow flag (V)

When carrying out twos complement arithmetic, errors can occur if large numbers are involved. For example if two positive numbers less than 12710 are added and produce a negative result (any value greater than 12710). This would cause the sign of the result (indicated by bit 7) to be wrong. The overflow flag gives an indication that an error has occurred by being set to 1 to indicate an ‘overflow error’. An error is sensed and the overflow flag is set when either of two conditions occurs.

There is a carry of logic 1 from bit 6 to bit 7 of the result, but the carry flip-flop is not at logic 1.

There is no carry from bit 6 to bit 7 of the result, but the carry flip-flop is at logic 1.

By using the carry-out from bit 6 and the carry-out from bit 7 of the result as inputs to an XOR gate, the output of the gate will be set to logic 1 for either of the above error conditions, signalling an overflow error at the overflow (V) flag.

The Zero flag (Z)

This flip-flop is set when every bit of the result is zero.

The Negative flag (N)

A negative result, i.e. bit 7 = 1 sets this flip-flop to logic 1.

The Flag Register

The status flags are individual bits of a register called the Flag Register  and are operative not only when the ALU is in addition mode, but also in all other arithmetic modes, the C flag is also operative in shift and rotate left modes. In microprocessors the flag register not only indicates ALU results, but can also be used in decision-making. For example the ALU can be used to compare (by subtracting) two values and take various actions depending on the state of particular flags; e.g. after comparing two values, A and B, an action may be taken if A = B, indicated by the zero flag being set to 1, otherwise (if the zero flag is set to 0) take no action.

Subtraction.

Subtraction is performed using  twos complements arithmetic That is, to subtract B from A, input B is complemented and 1 added to the complemented value to form the twos complement. Then the twos complement of B is added to A in the adder to find the result. To achieve this action with data A and data B present at the inputs, logic 1 is applied to the control inputs of MUX 1 and MUX 2. MUX 3 has logic 0 applied to its control input to complement data B, while the CARRY MUX has a logic 1 applied to its control line so that the carry-in (CIN) to the adder is forced to logic 1. This adds 1 to the result so that the twos complement of data B is added to data A. The result at the adder output is a twos complement number representing A - B. The flags are again set by the result as in the addition operation.

Counting with the ALU

Although the ALU does not include a binary counter circuit, it can also be used to count, by INCREMENTING or DECREMENTING, i.e. to add 1 to data A (incrementing), or subtract 1 from data A (decrementing). To count using this method would normally be carried out using (machine code or assembly language)software. A typical use could be to initiate a time delay by loading the ALU with some number, and then execute a looping routine to count down to zero by repeatedly decrementing data A. The zero result would be detected from the zero flag being set. However this would not be a common method, as the ALU (and therefore the CPU) would be occupied during the delay, and therefore not usable for other purposes. Most computer systems would also have dedicated counters for implementing similar time delays.

Incrementing.

Data A can be incremented if logic 1 is applied to the control inputs of MUX 1 and MUX 3. This will add B to A, with data B made zero by applying logic 0 to the control input of MUX 2. The 1 that must be added to data A is supplied by making the control input of the CARRY SELECT block logic 1, causing the carry input to the adder to be logic 1. The result at the adder output is therefore A + 1, again the flags are set by the result.

Decrementing.

To decrement data A, 1 must be subtracted from A. Because the ALU uses twos complement arithmetic, the twos complement of 1 added to A will in effect subtract 1 from A.

The twos complement of 1 is minus 1, which in 8-bit twos complement notation is 111111112. Therefore to subtract 1 from data A, data B must equal minus 1 (all bits = 1). To do this, and to make sure that the correct result is not changed by any data appearing on the data B input, logic 0 is applied to the control input of MUX 2 to make sure all data B bits = 0.

Logic 0 is also applied to the control input of MUX 3. This inverts data B, (which is 000000002) to give 111111112 at the adder input.

MUX 1 must have logic 1 on its control line, to apply data A to the other adder input. The adder’s carry input is set to 1 by applying logic 0 to the control line of the CARRY MUX. This ensures that, provided there is no carry-in on the CIN input, the correct result at the adder output will be A − 1.

Negation

Negation is simply the inverse of a value; therefore any value and its inverse will add to produce zero. In binary arithmetic the additive inverse of a value is its twos complement. The ALU can be used to negate (find the twos complement of) data A by complementing data A and then adding 1. This involves a similar process to decrementing, except that data B is treated differently, as follows:

The control input of MUX 1 is set to logic 0, which complements data A, also data B is made zero by putting logic 0 on MUX 2 control, and logic 1 on MUX 3. The Carry Select control input is set at logic 1, to add 1 to data A in the adder.

The shift register is used as a simple PIPO register  by applying logic 0 to the three shift controls and logic 1 to the ~CLC input to make sure the carry is not cleared. This gives a final result of A+1, which is the twos complement of A.

The Shift Operations

Shift operations are controlled by the four lower order control lines, R/~L controls the direction of shift or rotation, SHIFT/~LE has the dual purpose of enabling the shift operations if logic 1 is applied, or acting as a LOAD ENABLE when at logic 0, allowing the shift register to be loaded or reloaded with appropriate data. Each action of the shift register (shift, rotate or load) is actuated by a single CK pulse. Also note that the shift register in this design does not affect the V, N or Z flags.

Shift Left (with Carry)

In this mode (with control word 10100101) input data B is kept at zero and, after the shift register is loaded by temporarily making SHIFT/~LE logic 0 to move data from input A into the shift register, shift is enabled by returning SHIFT/~LE to logic 1, and both ROTATE and ~CLC are disabled. The data in the shift register will now shift one bit to the left with each CK pulse applied. This appears to multiply the value of the data by two for each shift left, but it is a very limited multiplication operation, because the result is reduced each time the left most bit is lost as it passes through the carry bit. This action is therefore considered a logical, rather than an arithmetic shift.

Rotate Left (with Carry)

If rotate is activated by applying logic 1 to the ROTATE control input with SHIFT/~LE and ~CLC also at logic 1, the data being shifted left from bit 7 and through the carry flag, is returned via the CIN input of the shift register to re-enter at bit 0 by the action of the ROTATE MODE SELECT data selector.

Rotate Right

When data in the shift register is rotated right, it leaves the register via bit 0 and is returned directly to bit 7 via an internal link, without passing through the carry flag.

There are a number of other operations, such as performing 8 bit logic functions, commonly found on microprocessors that this ALU is not designed to do. The purpose of this design is to illustrate how the circuits described in Digital Electronics Modules 1 to 5 are really just part of a bigger picture, they can be inter-connected in many ways to make many different circuits. This ALU design is one example, but how you use what you learn from the pages of learnabout-electronics and how you fit that knowledge into your own imagination is up to you.

The document The Status Flags | Digital Electronics - Electrical Engineering (EE) is a part of the Electrical Engineering (EE) Course Digital Electronics.
All you need of Electrical Engineering (EE) at this link: Electrical Engineering (EE)
115 videos|71 docs|58 tests

Top Courses for Electrical Engineering (EE)

FAQs on The Status Flags - Digital Electronics - Electrical Engineering (EE)

1. What are the status flags?
Ans. The status flags are a set of binary flags that indicate the status of a computer's processor. They are used to represent various conditions or outcomes of instructions executed by the processor.
2. How many status flags are there?
Ans. The number of status flags can vary depending on the specific processor architecture. However, a commonly used processor architecture like x86 typically has several status flags, including the carry flag, zero flag, sign flag, overflow flag, and parity flag.
3. What is the carry flag and how is it used?
Ans. The carry flag is a status flag that indicates whether an arithmetic operation resulted in a carry or borrow. It is commonly used for operations involving numbers that are too large to fit in a single register. The carry flag can be checked and manipulated by conditional jump instructions or other branching instructions to perform different actions based on its value.
4. How does the zero flag work?
Ans. The zero flag is a status flag that indicates whether the result of an arithmetic or logical operation is zero. It is set to 1 if the result is zero and set to 0 otherwise. The zero flag is often used in conditional jump instructions to determine the flow of execution based on whether a value is zero or not.
5. What is the significance of the sign flag?
Ans. The sign flag is a status flag that represents the sign of the result of an arithmetic or logical operation. It is set to 1 if the result is negative (i.e., has the most significant bit set to 1) and set to 0 otherwise. The sign flag is commonly used in conditional jump instructions to perform different actions based on whether the result is positive or negative.
115 videos|71 docs|58 tests
Download as PDF
Explore Courses for Electrical Engineering (EE) exam

Top Courses for Electrical Engineering (EE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Important questions

,

shortcuts and tricks

,

Extra Questions

,

pdf

,

Objective type Questions

,

video lectures

,

Exam

,

MCQs

,

The Status Flags | Digital Electronics - Electrical Engineering (EE)

,

study material

,

mock tests for examination

,

The Status Flags | Digital Electronics - Electrical Engineering (EE)

,

ppt

,

Semester Notes

,

The Status Flags | Digital Electronics - Electrical Engineering (EE)

,

Previous Year Questions with Solutions

,

Summary

,

Free

,

Sample Paper

,

Viva Questions

,

practice quizzes

,

past year papers

;