<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Fri, 23 Jul 2010 10:14:28 +0100
From   : jgh@... (J.G.Harston)
Subject: Spitting expletives

Michael Firth wrote:
> If the B flag was always false when popped off the stack, how would you
> (simply) be able to tell whether the value that had been pushed to the
> stack by the IRQ, BRK or PHP had B set to true or false?
> Or is the theory that you pull the value into A and then do a CMP to
> find out whether the B position would have been set?

Correct. Standard 6502 IRQ code starts off:

.irqhandler
STA irqtmp     ; Save A
PLA            ; Get stacked flags
PHA            ; Put back again
AND #16        ; Check BRK flag
BNE brkhandler ; BRK occured
; continue with IRQ handler
LDA irqtmp     ; Restore A
RTI            ; Restore P and return

.brkhandler
; continue with BRK handler

IRQ also disables IRQs (ie, sets I) so irqtmp won't get trampled by
another IRQ interupting the IRQ handler.

-- 
J.G.Harston - jgh@...     
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>