AVR® Status Register

Last modified by Microchip on 2023/11/09 09:02

The Status register contains information about the result of the most recently executed arithmetic instruction. This information can be used for altering program flow in order to perform conditional operations. The Status register is updated after all the Arithmetic Logical Unit (ALU) operations. This will, in many cases, remove the need for using the dedicated compare instructions, resulting in faster and more compact code.

The Status register is not automatically stored when entering an interrupt routine and restored when returning from an interrupt. This must be handled by the software.

When addressing I/O Registers as data space using LD and ST instructions, the provided offset must be used. When using the I/O-specific commands IN and OUT, the offset is reduced by 0x20, resulting in an I/O address offset within 0x00-0x3F.

STATUS: Status Register

Status Register

bit 7 I: Global Interrupt Enable: The Global Interrupt Enable bit must be set for the interrupts to be enabled. The individual interrupt enable control is then performed in separate control registers. If the Global Interrupt Enable register is cleared, none of the interrupts are enabled independently of the individual interrupt enable settings. The I-bit (bit 7) is cleared by hardware after an interrupt has occurred and is set by the Return from Interrupt (RETI) instruction to enable subsequent interrupts. The I-bit can also be set and cleared by the application with the Set Global Interrupt Flag (SEI) and Clear Global Interrupt Flag (CLI) instructions, as described in the instruction set reference.
bit 6 T: Copy Storage: The Bit Copy instructions Bit Load (BLD) and Bit Store (BST) use the T-bit as a source or destination for the operated bit. A bit from a register in the register file can be copied into T by the BST instruction and a bit in T can be copied into a bit in a register in the register file by the BLD instruction.
bit 5 H: Half Carry Flag: The Half Carry Flag, H, indicates a half carry in some arithmetic operations. It is useful in Binary Code Decimal (BCD) arithmetic.
bit 4 S: Sign Flag, S = N xor V: The S-bit is always an exclusive or between the Negative Flag and the Two’s Complement Overflow Flag.
bit 3 V: Two's Compliment Overflow Flag: The Two’s Complement Overflow Flag, V, supports two’s complement arithmetic.
bit 2 N: Negative Flag: The Negative Flag, N, indicates a negative result in an arithmetic or logic operation.
bit 1 Z:  Zero Flag: The Zero Flag, Z, indicates a zero result in an arithmetic or logic operation.
bit 0 C: Carry Flag: The Carry Flag, C, indicates a carry in an arithmetic or logic operation.