65c816 Processor Flags
From SMWiki
The SNES has 10 processor flags which can alter the SNES' behaviour, depending on the bits set and cleared.
Contents |
Native mode
The 65c816 CPU has 9 different processor flags in native mode:
- Negative
- Overflow
- Accumulator register width
- Index register width
- Decimal mode
- IRQ Disable
- Zero Flag
- Carry flag
- Emulation mode
Often abbreviated as
E NVMXDIZC
Negative flag
It will get set when the last operation’s value is between $80-$FF or $8000-$FFFF (depending on 8/16-bit mode).
Overflow flag
Only four opcodes can affect the V flag, excluding REP, SEP and PLP. Those four opcodes are: CLV, ADC, SBC and BIT. This flag gets set when the result of the previous operation was "out of range", i.e. not betweeen -128 and +127 decimal. For instance, $90 + $C8 = $158, but it rolls around to $58. In decimal, this would be -112 + -56 = -168. -168 is not within (-128,+127), so overflow is set. You can use this flag along with branches and so on.
Accumulator register width
This register determines the A register's width. When it is clear, A = 16 bit. When it is set, A = 8-bit.
Index register width
This register determines the X and Y registers' width. When it is clear, X&Y = 16 bit. When it is set, X&Y = 8-bit.
Decimal mode flag
See Decimal Mode.
IRQ Disable flag
This disables the IRQ when it is set. Otherwise, it runs the IRQ.
Zero flag
This flag is set when the last operation's result is zero. Otherwise, it is clear. Often used with BEQ and BNE.
Carry flag
This flag is set on unsigned overflow for ADC ($00 roll over to $FF) or when underflow for SBC does not happen. It also gets set depending on the result of ASL/LSR/ROL/ROR and more.
Emulation Mode
If this flag is clear, the native mode is enabled. When it is set, the emulation mode is enabled. Emulation mode has a more limited 65c816 instructions set.
Emulation Mode
The 65c816 CPU has 8 different processor flags in emulation mode:
- Negative
- Overflow
- Unused
- Program Break Interrupt
- Decimal mode
- IRQ Disable
- Zero Flag
- Carry flag
- Emulation mode
Often abbreviated as
E NV-BDIZC
NV__DIZC
See explanations above
Unused flag
Self-explanatory.
Program Break Interrupt
This flag is set when BRK caused an interrupt.

