Page 1 of 1

How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 6:39 pm
by SkoolKid
How long can an interrupt be blocked on a 48K Spectrum before it's abandoned? I haven't been able to find any documentation on this specific question.

However, I have run the following code on Fuse:

Code: Select all

EI          ; T=69884
DEFS N,0xFB ; T=69888; N 'EI' instructions blocking interrupts
NOP         ; T=69888+N*4
and found that an interrupt occurs after the NOP when N=6, but not when N=7. Which implies that the answer is somewhere between 6*4=24 T-states and 7*4=28 T-states - if Fuse is behaving accurately.

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 6:53 pm
by edjones
32T on 48K, 36T on 128K, 32T on +2A/+3. Might be +/-1T from those based on temperature. The early or late timings issues. Not my speciality!

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 7:08 pm
by SkoolKid
edjones wrote: Thu Jan 04, 2024 6:53 pm 32T on 48K...
If that means an interrupt can be accepted within 0-31 T-states of a frame boundary, but not after that, then that seems to agree with my Fuse experiment. Thanks!

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 9:19 pm
by Stefan
I’m reading 32T at http://www.zxdesign.info/interrupts.shtml
A Z80 interrupt must not be held active for longer than is necessary as this may lead to the Z80 responding to it multiple times. It is documented somewhere that the ZX Spectrum holds the interrupt active for 32 T-states, which is long enough for all instructions to have time to respond to it, but is still long enough for it to be detected more than once.

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 9:28 pm
by ketmar
SkoolKid wrote: Thu Jan 04, 2024 7:08 pm If that means an interrupt can be accepted within 0-31 T-states of a frame boundary, but not after that, then that seems to agree with my Fuse experiment. Thanks!
yes. that's what all documentation says, at least, and what most emulators implement. it may be slightly different on clones, though.

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 9:42 pm
by ketmar
and, btw, yes, with just "EI:NOP" interrupt handler could be called twice. "EI:RET" will not work, though. ;-) that is, interrupt ACK and handler call is 19T. EI is 4T. and 4T NOP, because EI is delayed. this is 27T, so the machine could still have INTR active. "EI:RET" is 33T, though.

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 9:56 pm
by Stefan
Found a more explicit reference to a source:

https://mametesters.org/view.php?id=5924&nbn=1
According to p. 226 of Chris Smith's excellent book "The ZX Spectrum ULA : How to design a microcomputer" the ULA pulls the /INT pin low for exactly 32 T-states.

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 9:58 pm
by SkoolKid
ketmar wrote: Thu Jan 04, 2024 9:42 pm and, btw, yes, with just "EI:NOP" interrupt handler could be called twice...
Ooh, I didn't think of that. And sure enough, Fuse does indeed run an 'EI: NOP' interrupt service routine twice.

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 10:01 pm
by SkoolKid
Stefan wrote: Thu Jan 04, 2024 9:56 pm According to p. 226 of Chris Smith's excellent book "The ZX Spectrum ULA : How to design a microcomputer" the ULA pulls the /INT pin low for exactly 32 T-states.
You know, I might have come across something like that while searching for the answer to this question, but I wouldn't have understood what it meant in practical terms. I'm just not really a hardware person. :lol:

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 10:10 pm
by Stefan
SkoolKid wrote: Thu Jan 04, 2024 10:01 pm You know, I might have come across something like that while searching for the answer to this question, but I wouldn't have understood what it meant in practical terms. I'm just not really a hardware person. :lol:
Same here. I have always had the bliss of not having to think about /what/ generates an interrupt. Until now, it was just one of those things that occurred once a frame. I had not considered /what/ was generating that interrupt. My naive knee jerk thought it was the Z80. Duh, of course not.

In the case of the Spectrum it is the ULA pulling the interrupt signal (low or high or whatever :-)).

Funnily all this stuff falls into logical place.

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 10:17 pm
by 1024MAK
It's the ULA pulling the Z80 interrupt signal (/INT) low. Because in it's inactive state, it's logic high.

Mark

Re: How long can an interrupt be blocked?

Posted: Thu Jan 04, 2024 10:37 pm
by Stefan
SkoolKid wrote: Thu Jan 04, 2024 10:01 pm You know, I might have come across something like that while searching for the answer to this question, but I wouldn't have understood what it meant in practical terms. I'm just not really a hardware person. :lol:
In which case I can recommend watching - even though not for the Z80 - the complete control of the CPU was really pleasing and educational.

Re: How long can an interrupt be blocked?

Posted: Fri Jan 05, 2024 12:03 am
by ketmar
yeah, there are a lot of interesting info and answers in reverse-engineered ULA schematics. too bad that i can't read schematics (and most other programmers too, i guess ;-). i know that it is like a program in some low-level language (with implied parallelism in some places), so i hope that someday i'll learn to undertand it. ;-)