Status register
Encyclopedia
A status register or flag register (also: condition code register, program status word, PSW, etc.) is a collection of flag
bit
s for a processor
. An example is the FLAGS register
of the x86 architecture
.
The status register is a hardware register
which contains information about process state. Individual bits are implicitly or explicitly read and/or written by the machine code
instructions executing on the processor. The status register in a traditional processor design includes at least three central flags: Zero, Carry, and Overflow, which are tested via the condition codes that are part of many machine code instructions. A status register may often have other fields as well, such as more specialized flags, interrupt
enable bits, and similar types of information. During an interrupt, the status of the thread currently executing can be preserved (and later recalled) by storing the current value of the status register along with the program counter
and other active registers into the machine stack
or a reserved area of memory.
Flag (computing)
In computer programming, flag can refer to one or more bits that are used to store a binary value or code that has an assigned meaning, but can refer to uses of other data types...
bit
Bit
A bit is the basic unit of information in computing and telecommunications; it is the amount of information stored by a digital device or other physical system that exists in one of two possible distinct states...
s for a processor
Central processing unit
The central processing unit is the portion of a computer system that carries out the instructions of a computer program, to perform the basic arithmetical, logical, and input/output operations of the system. The CPU plays a role somewhat analogous to the brain in the computer. The term has been in...
. An example is the FLAGS register
FLAGS register (computing)
The FLAGS register is the status register in Intel x86 microprocessors that contains the current state of the processor. This register is 16 bits wide. Its successors, the EFLAGS and RFLAGS registers, are 32 bits and 64 bits wide, respectively...
of the x86 architecture
X86 architecture
The term x86 refers to a family of instruction set architectures based on the Intel 8086 CPU. The 8086 was launched in 1978 as a fully 16-bit extension of Intel's 8-bit based 8080 microprocessor and also introduced segmentation to overcome the 16-bit addressing barrier of such designs...
.
The status register is a hardware register
Hardware register
In digital electronics, especially computing, a hardware register stores bits of information, in a way that all the bits can be written to or read out simultaneously.The hardware registers inside a central processing unit are called processor registers....
which contains information about process state. Individual bits are implicitly or explicitly read and/or written by the machine code
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...
instructions executing on the processor. The status register in a traditional processor design includes at least three central flags: Zero, Carry, and Overflow, which are tested via the condition codes that are part of many machine code instructions. A status register may often have other fields as well, such as more specialized flags, interrupt
Interrupt
In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution....
enable bits, and similar types of information. During an interrupt, the status of the thread currently executing can be preserved (and later recalled) by storing the current value of the status register along with the program counter
Program counter
The program counter , commonly called the instruction pointer in Intel x86 microprocessors, and sometimes called the instruction address register, or just part of the instruction sequencer in some computers, is a processor register that indicates where the computer is in its instruction sequence...
and other active registers into the machine stack
Call stack
In computer science, a call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack"...
or a reserved area of memory.
The most common flags
Flag | Name | Description |
---|---|---|
Z | Zero flag Zero flag The Zero Flag is a single bit flag that is a central feature on most conventional CPU architectures . It is often stored in a dedicated register, typically called status register or flag register, along with other flags... |
Indicates that the result of an arithmetic or logical operation (or, sometimes, a load) was zero. |
C | Carry flag Carry flag In computer processors the carry flag is a single bit in a system status register used to indicate when an arithmetic carry or borrow has been generated out of the most significant ALU bit position... |
Enables numbers larger than a single word to be added/subtracted by carrying a binary digit from a less significant word to the least significant bit Least significant bit In computing, the least significant bit is the bit position in a binary integer giving the units value, that is, determining whether the number is even or odd. The lsb is sometimes referred to as the right-most bit, due to the convention in positional notation of writing less significant digits... of a more significant word as needed. It is also used to extend bit shifts and rotates in a similar manner on many processors (sometimes done via a dedicated X flag). |
S / N | Sign flag / Negative flag Negative flag In computer processor the negative flag or sign flag is a single bit in a system status register used to indicate whether the result of last mathematic operation resulted in a value whose most significant bit was set... |
Indicates that the result of a mathematical operation is negative. In some processors, the N and S flags are distinct with different meanings and usage: One indicates whether the last result was negative whereas the other indicates whether a subtraction or addition has taken place. |
V / O / W | Overflow flag Overflow flag In computer processors, the overflow flag is usually a single bit in a system status register used to indicate when an arithmetic overflow has occurred in an operation, indicating that the signed two's-complement result would not fit in the number of bits used for the operation... |
Indicates that the signed result of an operation is too large to fit in the register width using twos complement representation. |
P | Parity flag Parity flag In computer processors the parity flag indicates if the number of set bits is odd or even in the binary representation of the result of the last operation. It is normally a single bit in a processor status register.... |
Indicates whether the number of set bits of the last result is odd or even. |
See also
- Control registerControl registerA control register is a processor register which changes or controls the general behavior of a CPU or other digital device. Common tasks performed by control registers include interrupt control, switching the addressing mode, paging control, and coprocessor control.-CR0:The CR0 register is 32 bits...
- Flag byteFlag byteA flag word is a generic term for a word used to indicate conditions within a binary computer. In particular, the byte can be used to show up to 8 discrete conditions...
- Flag (computing)Flag (computing)In computer programming, flag can refer to one or more bits that are used to store a binary value or code that has an assigned meaning, but can refer to uses of other data types...
- FLAGS register (computing)FLAGS register (computing)The FLAGS register is the status register in Intel x86 microprocessors that contains the current state of the processor. This register is 16 bits wide. Its successors, the EFLAGS and RFLAGS registers, are 32 bits and 64 bits wide, respectively...