Jump to content
IGNORED

Definition of "IRQ"


Recommended Posts

I see the phrase "IRQ" mentioned and I'm not 100% sure of what it means.

 

From what I learned at university, an IRQ is an "Interrupt Request".

 

So can an IRQ be a vbi routine or a dli routine or both or neither?

 

I sense but am not sure that people are saying that you can use a DLI as an IRQ, just making it run much longer than they normally would. Is this right?

 

I've even seen it mentioned that the VBI has been completely disabled and instead code is running from a DLI on the final scanline of the screen. Why would somebody want to do this, what are the advantages? Is this an IRQ?

Link to comment
Share on other sites

The naming conventions vary over time and what particular platform you're talking about.

 

Interrupt is generally a condition where the running program is interrupted usually by an external source and the CPU pushes information away that allows the interrupt to be serviced then have normal program execution continue.

 

On 6502, NMI is essentially the same thing except the vectoring is different and it can't be disabled at the CPU level (notwithstanding exploiting the not previously documented 6502 bug which can see NMIs missed).

 

On the likes of 68000 and IBM mainframe CPUs, you have Exceptions as well. Generally an exception is an error in the program or attempt to access memory that doesn't exist. But it's not necessarily a problem regarding memory as that's how Virtual Storage is implemented on many systems.

 

Generally when we talk about IRQs they're something externally generated but can originate from the CPU e.g. BRK on 6502 and by other means on other CPUs.

 

 

Disabling VBI - can have advantages. Normal VBlank NMI is generated into the first scanline that normally can't have Antic graphics displayed after the normal 240. By using a DLI earlier on grants you more CPU time, in fact as many as 24 scanlines worth if you were to start it on the JVB instruction on a stock Display List.

Additionally the OS VBlank is sort of unfriendly towards games. Since Stage 2 can so easily be skipped it means deferred VBlank processing isn't guaranteed. And you can't fit too much into Stage 1 as it then creates problems with SIO and can cause unwanted display corruption since the DList pointer and colour registers get stored during Stage 2.

Link to comment
Share on other sites

There are IRQ's from the pokey chip as well, four different ones if I recall correctly. They don't interact with the video interrupts, they have their own jump table, and can be fired at a rate of your choosing within limits of the machine. They are usually used for sound I think, and I've used one for a mouse driver (written in C, believe it or not). Also the keyboard generates an IRQ on keypress.

Link to comment
Share on other sites

  • 2 weeks later...

I see the phrase "IRQ" mentioned and I'm not 100% sure of what it means.

 

From what I learned at university, an IRQ is an "Interrupt Request".

 

So can an IRQ be a vbi routine or a dli routine or both or neither?

 

I sense but am not sure that people are saying that you can use a DLI as an IRQ, just making it run much longer than they normally would. Is this right?

 

I've even seen it mentioned that the VBI has been completely disabled and instead code is running from a DLI on the final scanline of the screen. Why would somebody want to do this, what are the advantages? Is this an IRQ?

 

Strictly, an "IRQ" (Interrupt Request) is an electrical signal to the CPU from an outside source (like Antic or Pokey) telling the CPU "interrupt what you're doing and process this other thing".

 

There are a wide variety of things which generate IRQs. Most common are timers and hardware events like the vertical blank for video, or things like control lines on an I/O port.

 

On the 6502 and most other processors, an interrupt can be maskable or non-maskable. A maskable interrupt can be turned off or disabled in hardware, while a non-maskable interrupt (NMI) cannot. Typically, an NMI is used for things that are especially time sensitive.

 

There are often certain conditions in the processor which generate a similar condition known as an exception, but this is not strictly the same thing as an IRQ. Also, people often say "IRQ" when they really just mean "interrupt" or "interrupt handler" (referring to the code that is called to process the interrupt) but this is not really correct usage.

 

On the Atari, you get an IRQ from each vblank, and for any scanline where the display list indicates a DLI should occur. These are both NMI. A VBI or DLI routine would be an example of an interrupt handler processing the resulting interrupt.

 

If your display list specifies a DLI to occur on the last scanline, the interrupt handler can take much longer than DLIs from other scanlines. By "disabling the VBI" and using the DLI instead, someone is trying to gain more time in the interrupt handler and still get the same 50/60hz timing that a VBI would provide.

 

By the way, they're not really disabling the VBI interrupt at the hardware level, since it's an NMI that will always fire as long as the video is turned on. They're just disabling the handler that normally runs in response to the interrupt.

Link to comment
Share on other sites

Interrupts were the the one thing that gave me a lot of trouble as a kid in the '80s. I knew my program was running and I knew the OS was running but I had no clear concept of how that happened. The easiest way to think about it is that the 6502 will insert something akin to a virtual "JSR" into the code when something triggers the IRQ or NMI pins.* The processor will jump to addresses stored in the last few memory addresses (vectors, usually in ROM) so those must point to code which handles some special task then returns to the instruction that was about to be executed when the interrupt occurred (using RTI).

 

The thing that's important to know about interrupts is that they're for things that are time critical. DLIs let you run specific code on a specific line of the screen without the programmer having to manually count cycles or constantly poll video registers. IRQ's let you grab a byte that just came in via SIO or handle the key that was just pressed. Without interrupts, you'd always be checking for these events and you'd have much less time for the needs of your own program.

 

The only thing you need to know about DLIs is that they cannot be ignored by the CPU. When they happen, the CPU will jump to the address in the NMI vector. They are for the most critical events and Atari uses them for screen related things like DLI and VBL which is basically just a DLI on a fixed line. The 400/800 also used a third NMI for the RESET key, but that was changed in the XL line because the reset key wouldn't work if the CPU locked-up from an illegal instruction.

 

IRQ response can be enabled & disabled with an instruction so they're a bit more flexible and a pending IRQ will still be there when interrupts are re-enabled (but disabling them too long may cause you to lose data, such as if a new SIO byte comes in before you read the previous one).

 

An example of when you'd want to disable IRQs is when doing cycle exact code. Let's say we want a specific graphics manipulation to occur on line 50. We set a DLI for that line (or the one before it, followed by a WSYNC), and begin rapidly changing registers in the HBLANK. If IRQs are enabled, certain events could happen and our graphics change might be delayed, causing the screen to glitch. So, we enable IRQs after making the necessary changes. Note that IRQs are automatically disabled when either an NMI or IRQ is processed, so it's up to you when you're ready to allow another IRQ. If you don't re-enable them, they'll be enabled when you return (RTI) from your interrupt code and the original processor status is pulled from the stack.

 

This explains the nitty-gritty of interrupt handing:

 

http://www.pagetable.com/?p=410

 

* what it actually inserts is a BRK instruction, but it's the jump-on-cue aspect that's most important.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...