How clever engineers made a cheap computer powerful
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 http://www.z80.info/1653.htm 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 http://www.breakintoprogram.co.uk/computers/zx-spectrum/interrupts explains how the Spectrum does it. It's quite clever. Go and have a look!
Credits:
Sinclair 48K ZX Spectrum motherboard - Bill Bertram
Commodore 64 Rev A. PAL motherboard - Bill Bertram
Texas Instruments TI-99 computer - Rama & Musée Bolo
Dragon 32 - Liftarn, Editing by: Bill Bertram
Byte Magazine, September and October 1982
Bus Queue - Jimmcgovern15
Social Media
============
Twitter: https://twitter.com/ncot_tech
Ko-Fi: https://ko-fi.com/ncot_tech
Web version: https://ncot.uk/spectrum-next/Clever-engineering-on-a-budget-ZX-Spectrum-Interrupts
Chapters
========
00:00 - Start
00:37 - Brief history of the Spectrum
02:10 - Polling and Interrupts
03:49 - Z80 Interrupts
05:20 - Z80 Interrupt Modes
06:11 - Z80 IM2
09:54 - Final Words
#Programming
#Z80 Interrupts
#ZX Spectrum
Video Title: Clever engineering on a budget - ZX Spectrum Interrupts