How long can an interrupt be blocked?

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
SkoolKid
Manic Miner
Posts: 407
Joined: Wed Nov 15, 2017 3:07 pm

How long can an interrupt be blocked?

Post 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.
SkoolKit - disassemble a game today
Pyskool - a remake of Skool Daze and Back to Skool
edjones
Drutt
Posts: 33
Joined: Fri Feb 28, 2020 1:42 pm

Re: How long can an interrupt be blocked?

Post 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!
User avatar
SkoolKid
Manic Miner
Posts: 407
Joined: Wed Nov 15, 2017 3:07 pm

Re: How long can an interrupt be blocked?

Post 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!
SkoolKit - disassemble a game today
Pyskool - a remake of Skool Daze and Back to Skool
User avatar
Stefan
Manic Miner
Posts: 809
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: How long can an interrupt be blocked?

Post 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.
Last edited by Stefan on Thu Jan 04, 2024 9:29 pm, edited 1 time in total.
User avatar
ketmar
Manic Miner
Posts: 713
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: How long can an interrupt be blocked?

Post 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.
User avatar
ketmar
Manic Miner
Posts: 713
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: How long can an interrupt be blocked?

Post 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.
User avatar
Stefan
Manic Miner
Posts: 809
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: How long can an interrupt be blocked?

Post 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.
User avatar
SkoolKid
Manic Miner
Posts: 407
Joined: Wed Nov 15, 2017 3:07 pm

Re: How long can an interrupt be blocked?

Post 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.
SkoolKit - disassemble a game today
Pyskool - a remake of Skool Daze and Back to Skool
User avatar
SkoolKid
Manic Miner
Posts: 407
Joined: Wed Nov 15, 2017 3:07 pm

Re: How long can an interrupt be blocked?

Post 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:
SkoolKit - disassemble a game today
Pyskool - a remake of Skool Daze and Back to Skool
User avatar
Stefan
Manic Miner
Posts: 809
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: How long can an interrupt be blocked?

Post 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.
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: How long can an interrupt be blocked?

Post by 1024MAK »

It's the ULA pulling the Z80 interrupt signal (/INT) low. Because in it's inactive state, it's logic high.

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
Stefan
Manic Miner
Posts: 809
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: How long can an interrupt be blocked?

Post 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.
User avatar
ketmar
Manic Miner
Posts: 713
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: How long can an interrupt be blocked?

Post 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. ;-)
Post Reply