Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user ATOO ! (Registered 2017-11-21) You are not logged in 
CSDb User Forums


Forums > C64 Coding > TIL: The instruction after SEI can be executed before a pending IRQ is handled
2017-11-07 16:56
Krill

Registered: Apr 2002
Posts: 902
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....
 
2017-11-12 13:25
Copyfault

Registered: Dec 2001
Posts: 216
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?
2017-11-12 13:29
Copyfault

Registered: Dec 2001
Posts: 216
...aehmm..
must ofcourse be
$ff48
!!inc $01!!
lda #$7f
sta $dc0d
...
2017-11-12 14:44
Krill

Registered: Apr 2002
Posts: 902
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?
2017-11-12 14:47
Groepaz

Registered: Dec 2001
Posts: 8275
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).
2017-11-12 14:58
Krill

Registered: Apr 2002
Posts: 902
Quoting Groepaz
writing 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! :)
2017-11-12 15:08
Oswald

Registered: Apr 2002
Posts: 4126
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.
2017-11-12 16:14
Groepaz

Registered: Dec 2001
Posts: 8275
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.
2017-11-12 17:20
Oswald

Registered: Apr 2002
Posts: 4126
"without SEI/CLI the broken setup might have not worked at all."

thank you.
2017-11-12 18:06
Krill

Registered: Apr 2002
Posts: 902
It's not uncommon that bugs cause erroneous behaviour only in the presence of other bugs. Fix only either, and the other lies dormant until some later time, fix both and you win. :)
2017-11-12 18:25
Groepaz

Registered: Dec 2001
Posts: 8275
indeed, that sei/cli stuff only masked other - and bigger - problems.
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Dymo
V-12/Tropyx
No-XS
Seven
sebalozlepsi
Guests online: 50
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Lunatico  (9.6)
6 Comaland 100%  (9.5)
7 Incoherent Nightmare  (9.5)
8 Wonderland XII  (9.5)
9 Comaland  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Pandemoniac Part 2 o..  (9.6)
2 FMX Music Demo  (9.6)
3 Daah, Those Acid Pil..  (9.5)
4 Dawnfall V1.1  (9.5)
5 Synthesis  (9.5)
6 Dawnfall  (9.4)
7 Treu Love [reu]  (9.4)
8 Field Sort  (9.4)
9 Pro Memoria 4  (9.3)
10 KAOS 64  (9.3)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 The Judges  (9.3)
Top Graphicians
1 Jok  (10)
2 JonEgg  (9.8)
3 Mirage  (9.8)
4 Archmage  (9.7)
5 Veto  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2017
Page generated in: 0.754 sec.