Statusregister

The status register (including state register, Eng. Condition code register CCR, or program status word, Eng. Program status word, PSW ) is a special register in the control unit of a microprocessor. Since these bits are referred to as flags, the status register is also called the flag register. It contains a set of flags that are set in response to the most recent arithmetic operation (eg, overflow, negative result ) of the arithmetic logic unit ( ALU). Some flags can also be changed by direct instructions. Some processors - such as the 6502 - put most of status flags even for pure load operations.

Use

Conditional (jump ) instructions depend exclusively on these flags, and some arithmetic operations of the ALU are influenced by the state of the flags.

The contents of the status register can be put on the stack in order to secure it. This happens automatically when an interrupt is called, so that the program can work undisturbed after the termination of the interrupt.

The nature and extent of the status register is dependent on the CPU architecture. A number of flags occur, however, in most of today's microprocessors. Among these flags:

  • The carry flag ( borrow or flag)
  • The zero flag
  • The Sign Flag ( also Negative flag)
  • The overflow flag
  • Adjust the flag ( also Auxiliary carry flag or Half- Carry Flag )
  • The Parity flag
  • The interrupt flag
  • The BCD flag

General flags of the status register

Carry flag

If this flag is set, then joined the last arithmetic operation on a carry, assuming unsigned operands. Was the last executed command a shift operation, this indicates the carry flag if a bit " pushed out " was.

Zero Flag

If the zero flag is set, then the last calculated result was zero.

In a comparison instruction will be two operands without changing it, subtracted internally. Then displays the zero flag that the two operands are equal.

Sign- Flag

For simplicity, use the two's complement microprocessors. It will be seen negative numbers because the most significant bit is set. The sign flag is set in accordance with this bit.

Overflow flag

If the overflow flag is set, then joined the last arithmetic operation, an overflow, assuming unsigned operands. When comparing (internal subtraction) of signed values ​​is required conditional branch instructions that depend beside the overflow flag and the sign flag.

Adjust flag

Having a microprocessor no special processing instructions for dual coded decimal digits ( BCD), it is often that flag present. It is set with "normal" binary arithmetic operations, when a carry from the nibble occurs; For example, in the addition of 9 and 7 = 16: 10012 01112 = 00002 1 This flag then indicates whether the result should be corrected.. 10012 01112 = 00012 * (101 ) 01102 * (100).

Other microprocessors have a BCD (status ) flag that can be set in advance whether the processor has to be expected as with "normal" binary numbers or as with dual -coded decimal digits.

Parity flag

If the number of ones ( checksum ) of a result in binary straight, so the parity flag is set. If the number is odd, then it is deleted. ( See: parity bit )

Interrupt Enable Flag

This flag is not a status flag, but a control flag. If it is deleted, interrupts are exposed by the processor. It clears this flag at the start of interrupt routines (some processors do this automatically) so that they can pass through undisturbed until the end. The processor executes after setting the interrupt enable flags yet a statement before allowing interrupts again. So you can still let run the RETURN instruction in an interrupt routine after put this flag.

There are interrupts that are not affected by the interrupt enable flag. These are called non- maskable interrupts ( NMI).

BCD flag

This flag is not a status flag, but a control flag. If it is set, the processor arithmetic works - ALU - in BCD mode rather than in purely binary arithmetic. This is intended mainly financial calculations carried out directly in the decimal system and inaccuracies in the conversion of binary fixed or floating-point numbers can be avoided.

200335
de