Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


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

Registered: Apr 2002
Posts: 2855
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!
2017-11-07 16:38
Mixer

Registered: Apr 2008
Posts: 422
Interesting. Any uses for this? Force NMI timing at stable raster? SEI + delay.
2017-11-07 17:54
White Flame

Registered: Sep 2002
Posts: 136
The 6502 implemented delay slots before delay slots were cool. ;-)
2017-11-07 20:39
Oswald

Registered: Apr 2002
Posts: 5031
well it makes sense 6502 have a kind of prefetch. guess hardwired behaviour doesnt wants to drop the instructions before executed.
2017-11-07 21:41
lft

Registered: Jul 2007
Posts: 369
This could lead to horrible bugs indeed, if sei/cli are used around critical sections (like Disable/Enable are often used in AmigaOS).

It's kind of neat that when this happens, the status register gets pushed with the I bit set. That way, RTI will correctly restore an environment in which interrupts are disabled.
2017-11-07 22:05
doynax
Account closed

Registered: Oct 2004
Posts: 212
Yet an RTI leaving the IRQs unacknowledged does not single-step. Evidently there is either or two cycles of pipelining involved.

I wonder though, is it possible to prove one cycle of latency in the mask register short of cheating with visual6502? Which of the PLP read cycles is the dummy one?

Incidentally this is common a number of architectures and the reason why interrupt barriers exist.
2017-11-08 07:45
ChristopherJam

Registered: Aug 2004
Posts: 1382
Wait, so if I understand that correctly if I have
  SEI
  {instruction1}
  {instruction2}

it's possible to get an interrupt *between* instructions one and two?

That could be Bad :(

Thanks for the heads up.
2017-11-08 08:01
JackAsser

Registered: Jun 2002
Posts: 1995
So, always nop after sei? :)
2017-11-08 08:24
ChristopherJam

Registered: Aug 2004
Posts: 1382
Eh, anything that doesn't access any memory outside the instruction stream should be fine.

Though if you're being really evil one might have to also remember to avoid using your interrupt handler to modify the instruction immediately following the SEI...
2017-11-08 11:22
chatGPZ

Registered: Dec 2001
Posts: 11149
yet another reason to forget this cargo cult of putting sei/cli around raster irq setup :)
2017-11-08 12:54
MagerValp

Registered: Dec 2001
Posts: 1060
I think you're reading the trace wrong. The next instruction following an SEI can be fetched, but not executed if an IRQ occurs during the SEI. The instruction will be re-fetched and executed following the RTI.

And yes, protecting IRQ setup with SEI/CLI is still wrong, but not for this reason :)
 
... 89 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 - 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
Yogibear/Protovision
A3/AFL
Flex/Artline Designs
Scrap/Genesis Project
TheRealWanderer
Lead/House Designs
sachy
csabanw
Operator Teleksu
Visage/Lethargy
Airwolf/F4CG
Guests online: 150
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 No Bounds  (9.6)
7 Comaland 100%  (9.6)
8 Aliens in Wonderland  (9.6)
9 Uncensored  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Happy Birthday Dr.J  (9.7)
2 Layers  (9.6)
3 It's More Fun to Com..  (9.6)
4 Cubic Dream  (9.6)
5 Party Elk 2  (9.6)
6 Copper Booze  (9.6)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Rainbow Connection  (9.5)
9 Dawnfall V1.1  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 SHAPE  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Elwix  (9.1)
5 A Life in Hell  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.05 sec.