| |
Krill
Registered: Apr 2002 Posts: 2980 |
TIL: The instruction after SEI can be executed before a pending IRQ is handled
As described here: http://visual6502.org/wiki/index.php?title=6502_Timing_of_Inter..
I never knew this, after all those years, and thought i'd share this as a heads-up.
Thanks to Bubis for pointing it out to me! |
|
... 89 posts hidden. Click here to view all posts.... |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Oh, and when assuming that some people run demos from a BASIC environment with all kinds of interrupts enabled, you can still disable all of them without SEI/CLI.
Unless its a truly hostile environment with interrupt handlers destroying register contents and setting up other interrupts, etc., as you describe, then
i dunno, the people running those don't deserve a demo treat. :) |
| |
Copyfault
Registered: Dec 2001 Posts: 478 |
I think Oswald is basically right here as he's just applying Murphy's Law to the coding of IRQs and their setups.
Then again, once you start optimizing (which is what C64 demo coding is all, no?) it's absolutely right to track down every unnecessary byte or cycle - even if it "feels odd" at first. Have also been using SEI/CLI ever since but I'm really happy and thankful to be enlightened by this discussion.
Just my 2c... |
| |
Copyfault
Registered: Dec 2001 Posts: 478 |
Hmm, upon further thinking, a basic raster IRQ setup could be done even shorter.
After basic start just switch to RAM
start:
lda #$34
sta $01
...
main:
<calculations done on irq-level=0>
...
and place the actual init routine @$ff48 in RAM:
$ff48
lda #$7f
sta $dc0d
lda #<irq
sta $fffe
lda #>irq
sta $ffff
etc.
So the CIA1-irq is misused for the init routine, which itself sets up everything as needed (and will ofcourse only be called once). It however assumes that (at least on irq-level=0) the cpu sees only RAM, i.e. that I/O is switched off there (which is how I always do it, i.e. having $01=$34 in level 0 and $01=$35 for higher irq-levels).
Or are there other traps I fail to see atm? |
| |
Copyfault
Registered: Dec 2001 Posts: 478 |
...aehmm..
must ofcourse be
$ff48
!!inc $01!!
lda #$7f
sta $dc0d
...
|
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Hmm, what does that setup from timer IRQ save? I don't see the shortening (and you'd also have to ack the IRQ yourself). :)
And please explain your notion of "irq-levels". How many are there? Are interrupt handlers themselves interrupted? Are there more banking settings than all-RAM ($30/$34) for main loop and with IO ($35) for interrupt handlers? Something going via $0314/15? |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
Quote:yeah, until you dont and start having bugs, which is always the case.
i know its useless to explain, but: mindlessly doing sei/cli and not thinking about when to do it and how to enable/disable the interrupts and their sources is what creates the bugs, not omitting it and knowing what to do. as a matter of fact, that kind of nonsense gave me a lot of headache in a certain demo i linked from parts made by a coder with the same mindset - and the whole "trick" to make it work flawless and bugfree was removing this sei/cli style interrupt setups and move them where they belong - and when they happen at the right time there is simply no need for sei/cli anymore (granted, it doesnt hurt either. however still doing it equals writing 0 to $d020 at random places, just to be sure the border is still black). |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quoting Groepazwriting 0 to $d020 at random places, just to be sure the border is still black Which then produces grey dots all over the place on many VICs, another pet peeve of mine! :) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Groppie, except your bugs werent caused by the sei/cli pair, but the irq setup wasnt timed correctly. and the bugs could have been even worse if those irq inits were interrupted by the raster irqs. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
again, let me write it in bold for you:
IF the IRQ setup had been timed correctly THEN SEI/CLI would not have been required. and Blindlessly using SEI/CLI made it "work" WITH THE BUGS.
and sure, without SEI/CLI the broken setup might have not worked at all. i totally prefer this over halfassed buggy glitchfest however. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
"without SEI/CLI the broken setup might have not worked at all."
thank you. |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 - Next |