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


Forums > C64 Coding > SEI considered harmful.
2023-10-30 05:16
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....
 
2023-10-31 11:59
Krill

Registered: Apr 2002
Posts: 2940
Okay then! =)
php
pla
ora #$04
pha
plp
2023-10-31 12:13
Martin Piper

Registered: Nov 2007
Posts: 698
Quote: Okay then! =)
php
pla
ora #$04
pha
plp


You beat me to it. :)
2023-10-31 12:36
spider-j

Registered: Oct 2004
Posts: 482
Quoting Krill
Okay then! =)
php
pla
ora #$04
pha
plp

*lol* Thank you Krill. Made my day :-)
2023-10-31 13:30
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 !-
2023-10-31 13:43
ChristopherJam

Registered: Aug 2004
Posts: 1402
KERNAL/BASIC only uses IRQs

CIA#1 ($dc00) - IRQ
CIA#2 ($dd00) - NMI

(and, lol @ Krill :D)
2023-10-31 14:34
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/
2023-10-31 15:54
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.
2023-10-31 16:20
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"
2023-10-31 22:15
Copyfault

Registered: Dec 2001
Posts: 468
Quoting Krill
My 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.
2023-10-31 23:10
Krill

Registered: Apr 2002
Posts: 2940
Quoting Copyfault
Quoting Krill
My 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
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
E$G/HF ⭐ 7
bugjam
alwyz/udi
MWR/Visdom
cobbpg
Scooby/G★P/Light
Jedfox/Exclusive ON
Tommy/Noice ^ Dual C..
Steffan/BOOM!
Mason/Unicess
zscs
Guests online: 142
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 Wonderland XIV  (9.6)
8 Comaland 100%  (9.6)
9 No Bounds  (9.6)
10 Unboxed  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Onscreen 5k  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Morph  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.2)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Cash  (9.6)

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