HOME About NCOT Documentation SineSoft Social Media Support Me

Drink tea and make things

Blog ZX Spectrum Next Computer Science Electronics Z80 Homebrew Computer Arduino and Microcontrollers

Clever engineering on a budget - ZX Spectrum Interrupts

Posted:

How do you make an underpowered 8 bit CPU seem a bit more capable than it really is? Interrupts! that mechanism where the CPU can be poked and told to do something completely different, then resume whatever it was originally doing as if it’d never stopped.

On the Spectrum - and in this instance I mean the original 16K Spectrum - this was done in a typical Sinclair way - cheaply, with as few components as possible, leaving the majority of the work to the programmer. I’m sure Sinclair HQ must have had a sign on their wall saying “if you can do it in software, we can build it cheaper” or something.

Let’s look at how those devious hardware designers crafted a cheap and functional system that didn’t exactly follow the Z80 specs.

You see the Spectrum was made to be cheap, like super cheap. Cheaper than any other home micro. And unlike cheap computers of the time, it was designed to be a usable computer.

Cheap computers of the time had a nasty habit of being severely crippled in one way or another. Maybe they had barely any RAM, or couldn’t do graphics or they were so insanely hard to program for nobody bothered. Maybe the screen blanked out every time you pressed a key.

So to make the machine cheap they put in as little hardware as possible. Inside a 48K spectrum there’s barely anything. Compare it to a C64 with its SID chip, VIC 2 chip, IO controllers… there’s none of that in a spectrum just a big ULA that does everything.

So CPUs are machines that follow very precise and mechanical processes. They fetch, decode and execute instructions one at a time. Some instructions take multiple cycles to complete, but it’s all very precise. Every time the CPU clock ticks, the CPU does a very specific task.

The real world isn’t quite as predictable. One way to deal with this is called polling. This is where the machine sits in a loop constantly checking for something interesting happening. Instead of polling, we can configure our devices to trigger interrupts to tell the CPU something needs its attention.

The website Z80 Info explains how the Z80 is supposed to do interrupts, however Sinclair were in an arms race to build the cheapest computer possible to beat their competitors. That meant using as little hardware as possible, and making the hardware work as cheaply as it could.

The website Break into program explains how the Spectrum does it. It’s quite clever. Go and have a look!

Related Content