Skip to main content

The Analytical Engine vs. The ZX81

Many people got started with computing in my age group with the Sinclair ZX81 (which in the US was sold as the Timex Sinclair 1000).

Reading through Allan Bromley's excellent papers on Babbage's Analytical Engine (as described in 1847) I thought it might be fun to compare the two machines.

The ZX81 has 1KB of memory in which programs and data had to be stored. The Analytical Engine as first imagined would have had 50 variables capable of each storing a 30 digit decimal number. That's equivalent to each variable having 100 bits and hence the memory for the Analytical Engine would have been 5000 bits (675 bytes). Later Babbage proposed much larger memory sizes with up to 50 decimal digits per variables and 1000 variables: that would have been a memory of 166 bits per variable or over 20 KB of memory.

Critically, the Analytical Engine's programs would be stored on punched cards and executed directly from them so that entire memory space was for data (not the program). In contrast the ZX81 had to load the program from magnetic tape into its 1KB of RAM.

But the ZX81 was much, much faster than Babbage's machine. It had a clock speed of 3.25 MHz. The Analytical Engine was based around a standard cycle time of 1/7s which is the same as 7Hz. To get an idea of the speed of the machines, here's a comparison of a 100 bit add on the two machines.

On the Analytical Engine it would take about three seconds to fetch the two numbers from memory (the store) and perform the addition. Although this is long Babbage added the ability to do a pipeline of multiple additions with overlapped reads from memory and addition happened in parallel. The ZX81 does not have that ability.

On the ZX81 in Z80 assembler a 100 bit addition (which I've done as 13 8-bit additions here) could be implemented as follows. I've assumed that IX and IY are pointing to the operands in memory and that the result will be stored in the memory addressed by IY.

LD A,(IX+0)
ADD A,(IY+0)
LD (IY+0),A
LD A,(IX+1)
ADC A,(IY+1)
LD (IY+1),A
LD A,(IX+2)
ADC A,(IY+2)
LD (IY+2),A


LD A,(IX+12)
ADC A,(IY+12)
LD (IY+12),A

Each instruction there takes 19 clock cycles and there are a total of 39 instructions giving 741 clock cycles. With the Z80 running at 3.25MHz that set of instructions takes 0.228 ms. So for that addition the ZX81 would have been 13,000x faster.

Obviously, this is slightly bogus because there are other more complex and slow instructions in the Analytical Engine (such as division) but it gives an idea of the scale.

So, the ZX81 had much less RAM than the Analytical Engine (and who doesn't remember all the trouble of fitting everything into RAM on those machines) and was forced to use it to hold programs, but the Analytical Engine was slow in comparison.

PS If you'd like to see the Analytical Engine built, read this.


aglemann said…
"So, the ZX81 had much less RAM than the Analytical Engine"

I thought I read from your description that the ZX81 had 1KB of RAM and the AE 0.375KB - am I missing something?
I was comparing the AE proposed top memory of 20KB with the ZX81's 1KB. I will modify the text to make that clearer.
Anonymous said…
Indexed instructions are fairly slow, so it'd be faster switching to using DE+HL instead of IX+IY.


7+7+7+6+6=26T compared to 19+19+19=57T for the index register method – twice as fast!

You can save a further 4T by incrementing only the low byte of the pair, if the values are arranged so they don't span 256-byte boundaries.
Unknown said…
You could get a 16KB RAM expansion pack for the ZX81 for about £50 (and you could play 3D Monster Maze on it too)
Carlos Valiente said…
"In contrast the ZX81 had to load the program from magnetic tape[..]"

..for those of you whose elder brother let you use his tape recorded -- I had to type my programs a la Babbage :-)
Richard Jones said…
Actually the Z80 did some very simple pipelining. It was able to overlap the fetch of the next instruction while retiring the previous instruction.

Unknown said…
Babbage invented pipelining? In the 1840’s? Wow, incredible. Genius. (
Kurtkilgor said…
This comment has been removed by the author.
Lutyens said…
The ZX81 had to use the 1KB for the display file too, so even basic AE may have had more memory. If you plug in the 16KB RAM pack, lots of memory, but did the Analytical Engine have an equivalent of the Ram pack wobble problem?
CodeMonkey said…
I feel the analytical engine is being undersold here. The Z80 add you show is in binary, the AE does a 2x50 digit addition in BCD. My quick attempt at a 50 + 50 BCD addition on a 3.25MHz Z80 is 0.5ms. I think the AE can do it in 4 cards:
Load Store to Mill
Load Store to Mill
Load Mill to Store
If that is 4 cycles @ 7Hz= 0.57s
The Z80 is "only" 1124 times faster
If the AE performs a multiplication in the same time as an addition (I am trying to find this out) I think the AE possibly could beat the Z80 here!!!
Now how about division, that is more complex/slower than multiplication.
Again how many cycles does the AE take to do a division?
CodeMonkey said…
Curses I am undone!
The AE is (of course) multicyclic on multiplications and divisions.
Babbage had invented some clever look ahead mechanics but it looks like it would still take 59 cycles @ 7Hz ie 8.5 seconds to do a 50 x 50 decimal multiplication. The Z80 is going to beat it.
HOWEVER what about comparing it to the "first" microprocessor- the Intel 4040........

Popular posts from this blog

How to write a successful blog post

First, a quick clarification of 'successful'. In this instance, I mean a blog post that receives a large number of page views. For my, little blog the most successful post ever got almost 57,000 page views. Not a lot by some other standards, but I was pretty happy about it. Looking at the top 10 blog posts (by page views) on my site, I've tried to distill some wisdom about what made them successful. Your blog posting mileage may vary. 1. Avoid using the passive voice The Microsoft Word grammar checker has probably been telling you this for years, but the passive voice excludes the people involved in your blog post. And that includes you, the author, and the reader. By using personal pronouns like I, you and we, you will include the reader in your blog post. When I first started this blog I avoid using "I" because I thought I was being narcissistic. But we all like to read about other people, people help anchor a story in reality. Without people your bl

Your last name contains invalid characters

My last name is "Graham-Cumming". But here's a typical form response when I enter it: Does the web site have any idea how rude it is to claim that my last name contains invalid characters? Clearly not. What they actually meant is: our web site will not accept that hyphen in your last name. But do they say that? No, of course not. They decide to shove in my face the claim that there's something wrong with my name. There's nothing wrong with my name, just as there's nothing wrong with someone whose first name is Jean-Marie, or someone whose last name is O'Reilly. What is wrong is that way this is being handled. If the system can't cope with non-letters and spaces it needs to say that. How about the following error message: Our system is unable to process last names that contain non-letters, please replace them with spaces. Don't blame me for having a last name that your system doesn't like, whose fault is that? Saying "Your

The Elevator Button Problem

User interface design is hard. It's hard because people perceive apparently simple things very differently. For example, take a look at this interface to an elevator: From flickr Now imagine the following situation. You are on the third floor of this building and you wish to go to the tenth. The elevator is on the fifth floor and there's an indicator that tells you where it is. Which button do you press? Most people probably say: "press up" since they want to go up. Not long ago I watched someone do the opposite and questioned them about their behavior. They said: "well the elevator is on the fifth floor and I am on the third, so I want it to come down to me". Much can be learnt about the design of user interfaces by considering this, apparently, simple interface. If you think about the elevator button problem you'll find that something so simple has hidden depths. How do people learn about elevator calling? What's the right amount of