| |
ChristopherJam
Registered: Aug 2004 Posts: 1402 |
SEI considered harmful.
Once more for the people at the back:
Don't wrap your interrupt initialisation with SEI/CLI.
It's a bad way to avoid interrupts being dispatched while you're changing the IRQ pointer, because it then requires additional code to acknowledge any pending CIA IRQs that might trigger between the SEI being executed and you turning off the CIA timer or interrupt enable.
If you're coming from BASIC, just do this instead:
lda #$7f
sta $dc0d
..then change $01, set your IRQ pointer(s), and init your own raster and/or timer IRQ(s)
If you're coming from a previous part, ask your teammate to turn off any IRQs and acknowedge any requests before they pass the baton (cf 'IRQ recovery' link below) - then all you need to do is set up your own IRQ.
As previously flogged to death at
TIL: The instruction after SEI can be executed before a pending IRQ is handled
C-64 coding cargo cults
Best practice IRQ recovery |
|
... 36 posts hidden. Click here to view all posts.... |
| |
Krill
Registered: Apr 2002 Posts: 2940 |
Okay then! =)
php
pla
ora #$04
pha
plp
|
| |
Martin Piper
Registered: Nov 2007 Posts: 698 |
Quote: Okay then! =)
php
pla
ora #$04
pha
plp
You beat me to it. :) |
| |
spider-j
Registered: Oct 2004 Posts: 482 |
Quoting KrillOkay then! =)
php
pla
ora #$04
pha
plp
*lol* Thank you Krill. Made my day :-) |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Wait a second... If the Kernal/Basic only uses NMIs, how come you can disable them with sei? I mean, if you do something like this:
!: inc $d020
jmp !-
You will see the code getting interrupted when pressing down keys. But start out with a sei, and there are no interruptions:
sei
!: inc $d020
jmp !-
|
| |
ChristopherJam
Registered: Aug 2004 Posts: 1402 |
KERNAL/BASIC only uses IRQs
CIA#1 ($dc00) - IRQ
CIA#2 ($dd00) - NMI
(and, lol @ Krill :D) |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Ah, CIA1 produces IRQs? Wow, how didn't I know this? Probably because you don't learn anything from just copy/pasting the same old block of code when doing interrupts. Glad I checked this thread so I won't forever be one of them people in the back. \o/ |
| |
Oswald
Registered: Apr 2002 Posts: 5074 |
Quote: KERNAL/BASIC only uses IRQs
CIA#1 ($dc00) - IRQ
CIA#2 ($dd00) - NMI
(and, lol @ Krill :D)
hitting restore (key) triggers an NMI, so no both are used. |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1402 |
Cruzer - glad something good came out of the thread :)
Oswald - ok ok, "KERNAL/BASIC doesn't use CIA#2 or VIC as interrupt sources" |
| |
Copyfault
Registered: Dec 2001 Posts: 468 |
Quoting KrillMy point was that the raster interrupt...
lda #0x01
sta 0xD019
; ... may trigger here
sta 0xD01A
; ... and then fire only here
rts
Should usually not be a problem, but... =) Really? Didn't some testprog show that it's more like
lda #0x01
sta 0xD019
; ... may trigger here
sta 0xD01A
; ... is ack'd here
rts ; ... next opcode is ececuted
; ... and irq routine starts here
? Thought this was the "result" of the TIL: The instruction after SEI can be executed before a pending IRQ is handled thread, no? In post #99 of this thread MagerValp linked the testprog I have in mind. |
| |
Krill
Registered: Apr 2002 Posts: 2940 |
Quoting CopyfaultQuoting KrillMy point was that the raster interrupt...
lda #0x01
sta 0xD019
; ... may trigger here
sta 0xD01A
; ... and then fire only here
rts
Should usually not be a problem, but... =) Really? Didn't some testprog show that it's more like
lda #0x01
sta 0xD019
; ... may trigger here
sta 0xD01A
; ... is ack'd here
rts ; ... next opcode is ececuted
; ... and irq routine starts here
? Thought this was the "result" of the TIL: The instruction after SEI can be executed before a pending IRQ is handled thread, no? In post #99 of this thread MagerValp linked the testprog I have in mind. Maybe. But that would just underline my point. =) |
Previous - 1 | 2 | 3 | 4 | 5 - Next |