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 > Force a queded IRQ
2017-05-27 08:12
oziphantom

Registered: Oct 2014
Posts: 490
Force a queded IRQ

Is there a way to pogrammatically ( without the CIAs ) to en-queue an IRQ from within an NMI?

BRK will interrupt an NMI.But is there some other trick, maybe some stack fiddling?
 
... 21 posts hidden. Click here to view all posts....
 
2017-05-27 09:15
oziphantom

Registered: Oct 2014
Posts: 490
A software interrupt.
However it can if needed rely on the fact it is in a NMI.

I doubt its possible, but you never know there might be some fancy trick to get it ;)
2017-05-27 10:09
TWW

Registered: Jul 2009
Posts: 545
You can trigger a SW interrupt whenever you want by using BRK or SEI/CLI in combination with a timer or raster IRQ which always is set to trigger.

I think I still don't get what you are trying to do ;-)
2017-05-27 10:33
oziphantom

Registered: Oct 2014
Posts: 490
BRK won't force an interrupt, as it will invoke the break handler right then and there, even if you are in an NMI.

So the ideal path is

Enter NMI
Do stuff
Optionally Queue IRQ
Do other stuff
Exit NMI
IRQ triggers when it can, if queued.
2017-05-27 10:46
Oswald

Registered: Apr 2002
Posts: 5094
how about setting up a raster irq (outside of available raster range), and using d019 to artifically fire a raster irq ? not sure if d019 can be used in this way tho.

similar thing could be achieved via timer interrupts too.
2017-05-27 11:46
Flavioweb

Registered: Nov 2011
Posts: 463
If you do a CLI as first instruction of your irq code, when another irq happens it will be triggered as well...
If it's what you mean...
2017-05-27 13:22
Mixer

Registered: Apr 2008
Posts: 452
If you wish to exit NMI directly to irq handler, you have to push the irq handler address to stack so that RTI fetches it correctly.

The irq handler then runs, but there is no flagged interrupt going on, so this execution can be interrupted, unless masked.

If you want some certain interrupt to take place, then set the conditions for that interrupt(VIC/CIA) etc.
2017-05-27 14:04
chatGPZ

Registered: Dec 2001
Posts: 11386
Quote:
BRK won't force an interrupt

in fact that is _exactly_ what a BRK does.
2017-05-27 17:04
White Flame

Registered: Sep 2002
Posts: 136
It's faster to just tail-call right into the IRQ, than it is to exit the NMI and then fake entering the IRQ handler via stack munging.

Neither the stack nor the interrupted program see any difference whether or not it was interrupted via NMI or IRQ, or if it were interrupted twice (NMI falling into IRQ after RTI) instead of once. If the prologues of both interrupt handlers match (which normally would be pushing regs to stack, instead of STA'ing them), you can do a "real" tail call:

nmi:
  prologue
  process
  test
  JMP irq_noprologue
  epilogue

irq:
  prologue
irq_noprologue:
  process
  epilogue


If the prologue/epilogue don't match, then you should do a simple test & compare after restoring saved registers. Since the processor status flags are restored as part of RTI, you don't have to worry about them, so a BCS or a BIT+BNE can perform the test right before the RTI instruction of the NMI handler, depending on how you saved the result of the decision to branch to IRQ.
2017-05-28 06:29
oziphantom

Registered: Oct 2014
Posts: 490
Quoting Groepaz
Quote:
BRK won't force an interrupt

in fact that is _exactly_ what a BRK does.


Fair I was loose with my terminology.
BRK won't force an IRQ.
It will force a jump to the FFFE/FFFF vector, but not under the rules of an IRQ.
2017-05-28 06:39
Flavioweb

Registered: Nov 2011
Posts: 463
Quote: BRK won't force an interrupt, as it will invoke the break handler right then and there, even if you are in an NMI.

So the ideal path is

Enter NMI
Do stuff
Optionally Queue IRQ
Do other stuff
Exit NMI
IRQ triggers when it can, if queued.


Isn't this the normal behaviour of a maskable irq triggered during a NMI?
Previous - 1 | 2 | 3 | 4 - 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
csabanw
Freeze/Blazon
AArt1256/MoonShine
wacek/arise
Steffan/BOOM!
E$G/HF ⭐ 7
El Gato
slimeysmine
Guests online: 107
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

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