enum CPU::Flags
Overview
The flags of the cpu
Defined in:
cr6502/6502.crEnum Members
-
Negative =
0 -
The Sign Flag
Sign Flag serves TWO purposes
- To signify the sigN of the last mathematical or bitwise operation. The sign is the bit-7 of the result value. If the last operation was not a signed operation, P.N will still reflect bit-7 of the result, but will NOT be considered as a sign.
- As a result store for a
CPU#bitinstruction: TheCPU#bitinstruction reads the contents of the specified memory address and copies bit-7 of that value to the Sign Flag
-
Overflow =
1 -
The Overflow Flag
P.V serves TWO purposes
- To signify an oVerflow (a sign change) during a mathmatical operation. Caused by an
CPU#adcorCPU#sbcinstruction: If anCPU#adcorCPU#sbcinstruction generates a result that would require more than 8 bits to hold (that is, any number outside the range -128 to 127) then Overflow is SET; else Overflow is CLEARed. This flag may be ignored if the programmer is NOT using signed arithmetic. - As a result store for a
CPU#bitinstruction: TheCPU#bitinstruction reads the contents of the specified memory address and copies bit-6 of that value to P.V
- To signify an oVerflow (a sign change) during a mathmatical operation. Caused by an
-
Break =
2 -
The Break Flag
The Break Flag and the
CPU#brkinstruction seem to me to be one very badly thought out bodge. If you do not plan to use theCPU#brkinstruction I would just ignore it! P.B is never actually set in the Flags register! When aCPU#brkinstruction occurs the Flags are PUSHed onto the Stack along with a return address* It is only this copy of the Flags (the one on the Stack) that has P.B set!- This return address is actually "Address_of_BRK_instruction+2".
Bearing in mind that the
CPU#brkinstruction is only ONE byte long... This means that if you simply issue anCPU#rti, The byte immediately following theCPU#brkinstruction will be ignored. I have read reasons as to WHY this is the case, but frankly they all stink! ...Just deal with it!
- This return address is actually "Address_of_BRK_instruction+2".
Bearing in mind that the
-
DecimalMode =
3 -
The Decimal Flag
P.D dictates whether Addition (
CPU#adc) and Subtraction (CPU#sbc) operate in the classic Binary or the more obscure Binary Coded Decimal (BCD) mode. -
InterruptDisable =
4 -
The Interrupt (disable) Flag
When P.I is SET, Interrupt ReQuest signals (IRQs) to the IRQ pin (classically pin-4) are IGNORED When P.I is CLEAR, signals to the IRQ pin are acknowledged.
-
Zero =
5 -
The Zero Flag
P.Z is SET when a zero value is placed in a register P.Z is CLEARed when a non-zero value is placed in a register
-
Carry =
6 -
The Carry Flag
P.C can be considered to be the 9th bit of an arithmetic operation.