[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Break Flag Is A Mystery



    I did a lot of research to study NMOS 6502 MPU and CMOS 65C02 MPU.  Most 
documentations allege to have 7 flags of the processor status register. 
65816 only has six flags excluding Break Flag in emulation mode and 8 flags 
are used in native mode.  I do know that Break flag does not exist.  Often, 
you test Break flag to use IRQ vector and know if it is BRK or IRQ.  Break 
flag is like a illusion in RAM.
    NMOS 6502 MPU has only six flags -- negative, overflow, decimal, 
interrupt request disable, zero, and carry.  Fifth flag and fourth flag are 
always "1" as reserved.  They are never changed.
    You want to use BRK for debugging.  BRK is executed to push two PC bytes 
and one processor status byte into stack before interrupt request disable 
flag is set to "1".  Only unchanged 5th and 4th reserved flags "1" including 
6 flags are copied into stack.  It does the same to do with PHP.  You do 
read P byte in stack and discover "1" on both 5th and 4th flags.
    You want to use NMI' or IRQ' to do hardware interrupts.  NMI' or IRQ' is 
executed to push two PC bytes.  Processor Status byte is copied into extra 
temporary register from processor status register.  Then, it masks 7 flags 
using "AND" 0xEF.  Processor status byte is copied from extra register into 
stack before interrupt request disable flag is set to "1".  You use PLA to 
read processor status byte when you want to test Break flag.  It is always 
zero.
    NMOS 6502 MPU and CMOS 65C02 MPU use BRK and IRQ to share the same IRQ 
vector when they test Break flag in memory only.  After BRK is executed in 
65816 MPU, it will go to a separated vector called BRK vector instead of IRQ 
vector so it does not need to test Break flag in memory unless it is in 
native mode.
    Only true documenation of NMOS 6502 MPU can be shown 1976 Synertek 
Programming Manual.  It is not necessary to prove 4th flag to be reserved, 
but you did obversation to know what Break flag is doing.  It is impossible 
to do reverse engineering to find out the truth, but it is sufficient to say 
that Break flag does not exist.
    It is ideal when you want to do more programming to manipulate IRQ' for 
Apple II using vector to $3FE-$3FF.

-- 

Yours Truly,
Bryan Parkoff