Discussion:
Interrupts question
(too old to reply)
Anthony Ortiz
2017-10-06 15:45:47 UTC
Permalink
Raw Message
I'm struggling to understand how a peripheral card can raise an IRQ/NMI. I know there's a line that can be pulled which the 6502 will detect and process the IRQ, one of the steps being to reset a flag that acks the IRQ, but what does that do? From an implementation standpoint, do the cards float the output to their (output) Interrupt pins and when it's time to issue an interrupt it pulls the line low for a cycle and then float it again? If someone could explain the flow, perhaps even with a simple serial port or mouse interrupt flow, I'd appreciate it.
Ralf Kiefer
2017-10-06 16:31:17 UTC
Permalink
Raw Message
Post by Anthony Ortiz
If someone could explain the flow, perhaps even with a simple serial port
or mouse interrupt flow, I'd appreciate it.
See Jim Sather, "Understanding the Apple IIe", page 4-16

- Ralf
Anthony Ortiz
2017-10-06 18:03:55 UTC
Permalink
Raw Message
I've read it and I'm still confused. For example, "the interrupt is acknowledged and IRQ goes high". Huh? How is it acknowledged? Who acknowledges it? What does that mean? Who pulls IRQ high?
MG
2017-10-06 18:33:41 UTC
Permalink
Raw Message
Post by Anthony Ortiz
I've read it and I'm still confused. For example, "the interrupt is acknowledged and IRQ goes high". Huh? How is it acknowledged? Who acknowledges it? What does that mean? Who pulls IRQ high?
In the case of the 6502, which has no hardware interrupt acknowledge, this means:

The interrupting device may continue to hold IRQ low until it is told not to, or it may hold IRQ for a minimum number of clock cycles to guarantee a response from the CPU (or it may detect the vector pull, etc).

In both cases, servicing the interrupting device serves as acknowledging the interrupt. In the former case, this must include telling the device to de-assert the IRQ line.

In any case, provided nobody else is asserting it, when IRQ is de-asserted it goes high because it has a pull-up resistor.

MG
Ralf Kiefer
2017-10-06 18:40:09 UTC
Permalink
Raw Message
Post by Anthony Ortiz
I've read it and I'm still confused. For example, "the interrupt is
acknowledged and IRQ goes high". Huh? How is it acknowledged? Who
acknowledges it? What does that mean? Who pulls IRQ high?
Ah, ok. There is a pullup resistor which pulls up the IRQ line, another
the NMI line. Any device which wants to attract attention pulls this
signal to low.

For example: you have several Super Serial Cards in your Apple, means
several 6551. They are configured to generate IRQs when transmitter
buffer is empty and receiver buffer is full. One 6551 has received one
byte: your IRQ service will ask the first 6551 if this is the source of
the interrupt (bit 7 of the status register), if not your IRQ service
will ask the next, ... The first device which is a source of an
interrupt must be serviced. Your IRQ service reads the whole status
register of that 6551 and sees bit 3 is set. The next step is reading
the data from that receiver data register so the IRQ source is
automatically cleared. If there is no more source for an interrupt of
that 6551 bit 7 of the status register is automatically cleared.

The IRQ line is an open drain output, means that several devices can
signal an interrupt condition. After clearing the last IRQ source the
IRQ signal will go high again because of the pullup.

There are a lot of different devices and there a lot of different ways
to clear their IRQ request. The 6551 is easy to understand. Read the
manual :-)

- Ralf
James Davis
2017-10-06 19:50:23 UTC
Permalink
Raw Message
Post by Anthony Ortiz
I'm struggling to understand how a peripheral card can raise an IRQ/NMI. I know there's a line that can be pulled which the 6502 will detect and process the IRQ, one of the steps being to reset a flag that acks the IRQ, but what does that do? From an implementation standpoint, do the cards float the output to their (output) Interrupt pins and when it's time to issue an interrupt it pulls the line low for a cycle and then float it again? If someone could explain the flow, perhaps even with a simple serial port or mouse interrupt flow, I'd appreciate it.
Hi Anthony,

Read: "Apple II Monitors Peeled," "Ch.3: Interrupt Processing." It explains both, what the Old Monitor and the Autostart Monitor do to handle all three types of interrups (IRQ, NMI, Reset). Read it along with assembly listings of the two Monitors.

Also: "Programming the 6502" by Rodney Zaks. It explains how the 6502 handles interrupts. No specific chapter; use its index to look up interrupts, IRQ, NMI, & Reset.

James Davis
Tom Porter
2017-10-08 02:51:16 UTC
Permalink
Raw Message
This is guarenteed to work on a mockingboard in slot4
DOS 3.3

... i just recently figured it out myself, make sure all the
pokes in the basic program are present, i think they 'help fix'
the code below.

If you need prodos, the method is slightly different.


1 PRINT CHR$(4);"BLOAD INT1"
2 PRINT CHR$(4);"BLOAD INT2"
3 POKE 32000,0:POKE 32001,0
4 POKE 30069,255:POKE 30074,64
5 HOME:CALL 30040
6 VTAB 10:PRINT PEEK(32000);" ",PEEK(32001);" ":GOTO 6


INT1
7558- A9 00 LDA #$00
755A- 8D FE 03 STA $03FE
755D- A9 85 LDA #$85
755F- 8D FF 03 STA $03FF
7562- A9 40 LDA #$40
7564- 8D 0B C4 STA $C40B
7567- A9 7F LDA #$7F
7569- 8D 0E C4 STA $C40E
756C- A9 C0 LDA #$C0
756E- 8D 0D C4 STA $C40D
7571- 8D 0E C4 STA $C40E
7574- A9 FF LDA #$FF
7576- 8D 04 C4 STA $C404
7579- A9 40 LDA #$40
757B- 8D 05 C4 STA $C405
757E- 58 CLI
757F- 60 RTS

INT2
8500- A5 45 LDA $45
8502- 48 PHA
8503- 98 TYA
8504- 48 PHA
8505- 8A TXA
8506- 48 PHA

----this is code in middle of interrupts
8507- A9 7f LDA #$7f
8509- 8D 0D C4 STA $C40D
850C- EE 00 7D INC $7D00
850F- D0 03 BNE $8514
8511- EE 01 7D INC $7D01

----
8514- 68 PLA
8515- AA TAX
8516- 68 PLA
8517- A8 TAY
8518- 68 PLA
8519- 40 RTI

-----------DECIMAL BELOW...----------

IDIOT DISASEMBLER V.57
FILE: INT1

30040- A9 00 LDA #0
30042- 8D FE 03 STA 1022
30045- A9 85 LDA #133
30047- 8D FF 03 STA 1023
30050- A9 40 LDA #64
30052- 8D 0B C4 STA 50187
30055- A9 7F LDA #127
30057- 8D 0E C4 STA 50190
30060- A9 C0 LDA #192
30062- 8D 0D C4 STA 50189
30065- 8D 0E C4 STA 50190
30068- A9 FF LDA #255
30070- 8D 04 C4 STA 50180
30073- A9 40 LDA #64
30075- 8D 05 C4 STA 50181
30078- 58 CLI
30079- 60 RTS

IDIOT DISASEMBLER V.57
FILE: INT2

34048- A5 45 LDA 69
34050- 48 PHA
34051- 98 TYA
34052- 48 PHA
34053- 8A TXA
34054- 48 PHA
34055- A9 7f LDA #127
34057- 8D 0D C4 STA 50189
34060- EE 00 7D INC 32000
34063- D0 03 BNE 34068
34065- EE 01 7D INC 32001
34068- 68 PLA
34069- AA TAX
34070- 68 PLA
34071- A8 TAY
34072- 68 PLA
34073- 40 RTI

Loading...