Query re C64 interrupt routine [message #104470] |
Tue, 01 March 2005 19:01 |
Ian Kenny
Messages: 21 Registered: January 2005
Karma: 0
|
Junior Member |
|
|
I have a question about the interrupt code in the C64 rom that starts at
FF48. Specifically from FF4D to the branch at FF53. I can understand it as a
piece of assembly code but what is being tested here?
Here's the code:
FF4D TSX
FF4E LDA, $104,X
FF51 AND #$10
FF53 BEQ $FF58
The code then either branches to the 'normal interrupt routine' or to the
'BRK routine'. I just can't see how that particular test makes the decision.
Cheers
Ian
|
|
|
Re: Query re C64 interrupt routine [message #104472 is a reply to message #104470] |
Tue, 01 March 2005 19:55 |
Anton Treuenfels
Messages: 105 Registered: December 2011
Karma: 0
|
Senior Member |
|
|
Ian Kenny wrote:
> I have a question about the interrupt code in the C64 rom that starts at
> FF48. Specifically from FF4D to the branch at FF53. I can understand it as a
> piece of assembly code but what is being tested here?
>
> Here's the code:
>
> FF4D TSX
> FF4E LDA, $104,X
> FF51 AND #$10
> FF53 BEQ $FF58
When an interrupt occurs the hardware stored the status flags and program
counter on the stack before loading the shared IRQ/BRK vector into the program
counter. This code recovers the stacked status flag and checks the break flag.
It's set if the interrupt was caused by a BRK instruction, clear if caused by an
IRQ.
Checking the stacked break flag is actually the only way to tell the difference
between the two.
Well, I suppose the service routine could recover the saved program counter and
see if the byte at PC-2 is a BRK instruction, but that byte might be $00 for any
number of reasons.
- Anton Treuenfels
|
|
|
Re: Query re C64 interrupt routine [message #104590 is a reply to message #104472] |
Wed, 02 March 2005 09:30 |
Ian Kenny
Messages: 21 Registered: January 2005
Karma: 0
|
Junior Member |
|
|
Aah, of course. Thanks.
> When an interrupt occurs the hardware stored the status flags and program
> counter on the stack before loading the shared IRQ/BRK vector into the
> program
> counter. This code recovers the stacked status flag and checks the break
> flag.
> It's set if the interrupt was caused by a BRK instruction, clear if caused
> by an
> IRQ.
>
> Checking the stacked break flag is actually the only way to tell the
> difference
> between the two.
> Well, I suppose the service routine could recover the saved program
> counter and
> see if the byte at PC-2 is a BRK instruction, but that byte might be $00
> for any
> number of reasons.
>
> - Anton Treuenfels
>
|
|
|