Processor Status Register

From C64-Wiki
(Redirected from Processor status flag)
Jump to: navigation, search

The Processor Status Register (abbreviated as P) is a hardware register which records the condition of the CPU as a result of arithmetic, logical or command operations. The purpose of the Processor Status Register is to hold information about the most recently performed ALU operation, control the enabling and disabling of interrupts and set the CPU operating mode.


The condition of the MOS Technology 65xx CPUs is recorded by seven combined processor flags and control flags (all within a single byte). Each flag corresponds to a single bit within the Processor Status Register which are explicitly or implicitly read and/or written. When writing, the bits are set (1 or true) or cleared (0 or false). Table 1 lists the seven flags (as named by MOS Technology) in the Processor Status Register.

Table 1 - Flags of the MOS Technology 65xx Processor Status Register
Bit Flag Abbreviation Purpose
0 Carry Flag C Indicates when a bit of the result is to be carried to, or borrowed from, another byte.
1 Zero Flag Z Indicates when the result is equal, or not, to zero.
2 Interrupt Request Disable Flag I Indicates when preventing, or allowing, non-maskable interrupts (NMI).
3 Decimal Mode Flag D Indicates when switching between decimal/binary modes.
4 Break Command Flag B Indicates when stopping the execution of machine code instructions.
5 Unused - Cannot be changed.
6 Overflow Flag V Indicates when the result is greater, or less, than can be stored in one byte (including sign).
7 Negative Flag N Indicates when the result is negative, or positive, in signed operations.

Diagrammatically this can be seen as:

Diagrammatic representation of the Processor Status Register

The most commonly used flags are C (bit 0), Z (bit 1), V (bit 6), N (bit 7).