The flags register in a processor determines the current state and is automatically modified after operations to indicate results. It contains status and control flags. The status flags include carry, zero, sign, overflow, parity, and auxiliary carry flags which provide information about results such as indicating carries, zeros, signs, overflows, even/odd parity, and nibble carries or borrows. The flags allow determining conditions and transferring program control.
This presentation is about the knowledge of computer memory which is critically study of Registers and flags in computer organization and computer architecture.
power point presentation regarding the number system conversions, representation of negative numbers and various codes of representations and error detection and correction codes.
Full information of about CPU register and type of CPU registers,
Use of registers in computer and their basic operation, category of registers and how to use them, flag register.
Flag?
Special registers. Because these are designed for specific purposes and are distinct/different from general purpose registers.
Size and meaning of flag bits in flags register is architecture dependent.
Each bit represents a specific condition or state of the processor.
Determines the current state of processor .
Depending upon the value of result after any arithmetic and logical operation the flag bits become set(1) or reset(0).
This presentation is about the knowledge of computer memory which is critically study of Registers and flags in computer organization and computer architecture.
power point presentation regarding the number system conversions, representation of negative numbers and various codes of representations and error detection and correction codes.
Full information of about CPU register and type of CPU registers,
Use of registers in computer and their basic operation, category of registers and how to use them, flag register.
Flag?
Special registers. Because these are designed for specific purposes and are distinct/different from general purpose registers.
Size and meaning of flag bits in flags register is architecture dependent.
Each bit represents a specific condition or state of the processor.
Determines the current state of processor .
Depending upon the value of result after any arithmetic and logical operation the flag bits become set(1) or reset(0).
The 8086 is a 16-bit microprocessor chip designed by Intel between early 1976 and June 8, 1978, when it was released. Wikipedia
Address width: 20 Bit
Co-processor: Intel 8087
Min. feature size: 3 µm
Max. CPU clock rate: 5 MHz to 10 MHz
Data width: 16 Bit
Instruction set: x86
This project is based on Data Path Architecture which consists of Shift register, MAC Unit, 16-Bit ALU and Tri-State Buffer. This whole architecture is implemented by using VHDL and simulated by using Modelsim.
2. Special Purpose Registers
• IP- the instruction pointer.
• Flags Register - determines the current state of the processor.
• IP register always works together with CS segment register and it
points to currently executing instruction.
• Flags Register is modified automatically by CPU after mathematical
operations, this allows to determine the type of the result, and to
determine conditions to transfer control to other parts of the
program. Generally you cannot access these registers directly
3. processor status register (or Flags)
• As you may see there are 16 bits in this register, each bit is
called a flag and can take a value of 1 or 0.
4. processor status register (or Flags)
• Bits of flag register are categorized into two portions
• Status Flags: bit 0, 2, 4, 6 and 11
• Control Flags: bit 8, 9 and 10
• Other bits have no significance
• All flags have specific names, we will call them by its names
5. processor status register (or Flags)
• Carry Flag (CF) - this flag is set to 1 when there is an unsigned
overflow. For example when you add bytes 255+1 (result is
not in range 0...255). When there is no overflow this flag is set
to 0.
• Zero Flag (ZF) - set to 1 when result is zero. For none zero
result this flag is set to 0.
• Sign Flag (SF) - set to 1 when result is negative. When result is
positive it is set to 0. Actually this flag take the value of the
most significant bit.
6. processor status register (or Flags)
• Overflow Flag (OF) - set to 1 when there is a signed overflow.
For example, when you add bytes 100 + 50 (result is not in
range -128...127).
• Parity Flag (PF) - this flag is set to 1 when there is even
number of one bits in result, and to 0 when there is odd
number of one bits. Even if result is a word only 8 low bits are
analyzed!
• Auxiliary Flag (AF) - set to 1 when there is an unsigned
overflow for low nibble (4 bits).
7. processor status register (or Flags)
• Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts
from external devices.
• Direction Flag (DF) - this flag is used by some instructions to process data
chains, when this flag is set to 0 - the processing is done forward, when this
flag is set to 1 the processing is done backward.
8. FlagsRegister(StatusRegister)
• A flag is a single bit of information whose meaning
is independent from any other bit
• Each flag has a two-letter symbol
9. CF - Carry Flag
1. If the result of an arithmetic or shift operation "carries out" a bit from the operand, CF becomes
set
11111111 + 00000001 = 100000000 CF = 1
2. The carry (borrow) flag is also set if the subtraction of two numbers requires a borrow into MSB
subtracted
00000000 - 00000001 = 11111111 CF = 1
• In unsigned arithmetic, watch the carry flag to detect errors.
• In signed arithmetic, the carry flag tells you nothing interesting.
00000000 - 00000001 = 11111111
• unsigned arithmetic => 11111111 = 255 (decimal) => got the wrong answer
• signed arithmetic => 11111111 = -1 (decimal) => got right answer, do not care about
value of CF
10. OF – Overflow Flag
1. If the sum of two numbers with the sign bits off yields a result number with the sign bit on, the
"overflow" flag is turned on.
0100 + 0100 = 1000 OF = 1
2. If the sum of two numbers with the sign bits on yields a result number with the sign bit off, the
"overflow" flag is turned on.
1000 + 1000 = 0000 OF = 1
3. Otherwise, the overflow flag is turned off.
0100 + 0001 = 0101 OF = 0
0110 + 1001 = 1111 OF = 0
1000 + 0001 = 1001 OF = 0
1100 + 1100 = 1000 OF = 0
• In signed arithmetic, overflow flag on means the answer is wrong - you added two positive
numbers and got a negative, or you added two negative numbers and got a positive.
• In unsigned arithmetic, the overflow flag tells you nothing interesting.
11. ZF – Zero Flag - set if result is zero; cleared otherwise
add 0, 0 ZF = 1
SF – Sign Flag becomes set when the result of an operation is negative (i.e. MSB of the result is 1)
• all arithmetic operations except multiplication and division
• compare instructions - CMP
• logical instructions - XOR, AND, OR
• TEST instructions (equivalent to AND instructions without storing the result)
sub 00000000, 00000001 11111111 SF = 1
PF – Parity Flag - set if low-order eight bits of result contain an even number of "1" bits; cleared
otherwise
add 11010, 1 (result is 11011 4 bits are ‘1’ PF = 1)
add 11000, 1 (result is 11001 3 bits are ‘1’ PF = 0)
AF – Auxiliary Carry Flag (or Adjust Flag) is set if there is a carry from low nibble (4 bits) to high nibble
or a borrow from a high nibble to low nibble
1111 + 0001 = 10000 AF = 1
first nibble second nibble
ZF, SF, PF, and AF Flags