[Ken Shirriff] Completely Reverse Engineers The 1974 Sinclair Scientific Calculator

Wow. Seriously… Wow! The work [Ken Shirriff] put into reverse engineering the Sinclair Scientific is just amazing. He covers so much; the market forces that led [Clive Sinclair] to design the device with an under-powered chip, how the code actually fits in a minuscule amount of space, and an in-depth look at the silicon itself. Stop what you’re doing and read it right now!

This calculator shoe-horned itself into the market when the HP-35 was king at a sticker price of $395 (around $1800 in today’s money). The goal was to undercut them, a target that was reached with a $120 launch price. They managed this by using a Texas Instruments chip that had only three storage registers, paired with a ROM totaling 320 words. The calculator worked, but it was slow and inaccurate. Want to see how inaccurate? Included in the write-up is a browser-based simulator built from the reverse engineering work. Give it a try and let us know what you think.

Now [Ken] didn’t do all this work on his own. Scroll down to the bottom of his post to see the long list of contributors that helped bring this fantastic piece together. Thanks everyone!

[Thanks Ed]

 

46 thoughts on “[Ken Shirriff] Completely Reverse Engineers The 1974 Sinclair Scientific Calculator

  1. Brilliant. Both the design of this calculator and Ken’s reverse engineering. Sir Clive definitely had a hacker mentality, years ahead of his time. Not much code needs to be written in assembly these days but it is definitely a place that can separate the men from the boys, programmatically speaking.

    1. Except for the poor trig accuracy. I bought one when I worked in an engineering planning department my first calculator. Replaced a Curta. Sadly, my seven-figure log book wasn’t yet obsolete.

  2. Back in the late 80’s I was preparing for my GCSE (high school) Maths exam. A day before the exam my Casio died. In the back of a drawer was an old Sinclair scientific calculator. It was a later model (but still with led display). This is what I used.

    I’m sure the whole hall heard the click-click-click of the buttons. But it worked great!

    Clive was genius when it came to reducing costs. There’s a story of him buying skip loads of reject components and paying people to test for those that working.

    1. “Sinclair was certainly an early convert to industrial recycling, as one incident shows. Texas Instruments at Bedford used a large batch of reject transistors as hardcore for a driveway. Sinclair found out about this, presumably through industry contacts, and rather than shrugging his shoulders at a missed opportunity negotiated a price for digging the whole lot up again! ” – http://www.nvg.ntnu.no/sinclair/audio/slimline.htm

    2. In more detail, he realised that a transistor that failed it’s specifications, would still meet *some* specifications. So he bought rejects that were still good enough, and sold them much cheaper with lower specs. And also incorporated them into audio amps, radio stuff, all sorts of kits and assembled stuff.

      His biography, published in the 1980s, is pretty interesting, mostly it’s a career biography. Apart from marrying Miss World and playing poker, not much is known about his personal life. He’s apparently quite short-tempered, which goes with being a redhead.

      1. At that time i was a teenager and worked for a one man business in England called Burkitts, who was one of the largest supplier of electronic components to amateurs and professional in the country. He also clicked onto this concept, and used to buy dumpsters of reject chips, transistors, capacitors, resistors, and even valves (vaccum tubes). I used to build custom test devices for each type of device so we could find the ones that were sellable as working but below spec. It was a very enjoyable 10 years, being able to build test gear with the practically unlimited and free resources of a major electronics shop at my disposal.

  3. Amazing!!! My brother Joaquin and I ordered the kit and mostly he put it together. We were so worried about damaging something in it. When we turned it on it worked perfectly. It was so amazing! I remember taking it to school and showing it off. Its RPN was interesting since there wasn’t any ENTER key and doing square roots or any other powerful operations required to manipulate logarithms. He still have it in perfectly working condition!!! We both love it. Amazing reverse engineering and explanation job!. And thanks to my brother Joaquin for ordering it and making us been part of history!!! Santiago

  4. you probably don’t know this, but your bold font is terrible on chrome on OS X. It’s ok on pretty much every other browser though. How do I know this? It’s the same font as /r/android uses.

  5. Great article. Engineering school in the mid 1970’s was wild and a time of change. Slide rules, trig tables, Wang desktop calculators with neon display (couldn’t read the 7,8, or 9 digits because it was so far back in the display) and the poor kid’s TI SR71. Only one kid had a HP35 because his dad was president of a coal company. Everyone who went to school then knew pi to 7 digits because there was no pi key. My engineering interns of today don’t know how good they have it.

  6. This is stuff people who are into RE always want to do but usually don’t have time to do. Embedded and legacy systems are far more interesting than today’s tech. Mostly because they are more informative and less dense. You try this with today’s tech you’re talking about a very long project only to find out a small subset of a specification or architecture..

    I think if you wanted to be a talented coder, on top of learning pure math, dumping old code from the days when you had to know the system, would give you an edge. The coding practices of this era are still used in rendering, animation, and kernel dev today..

    1. It had an instruction set! The “ROM” he shows on the page is the ALU’s instruction ROM, or in other words, the microcode. That gives it 32 opcodes, which you can see in the disassembly.

  7. One of the clever features is the lack of decimal point. By forcing all numbers to be entered as normalised scientific notation Sinclair/Searle were able to reduce the code required to handle numeric input AND release a precious key in order to access an extra 4 scientific functions*. Hence a scientific calculator with no decimal point key – Brilliant!

    [* The branch instructions on its CPU are designed to handle individual functions *or* the digits 0..9 . Thus it’s much easier to cram extra functions onto existing function keys than onto the digits].

    I had a feeling I persuaded my parents to buy me a Sinclair Scientific calculator, but being 8 years old at the time I couldn’t work it out so we swapped it for a Commodore 796M (d’oh!)

    1. Good point about placing functions on non-digits. Note also that there’s no Enter key, unlike most RPN calculators. You always start by adding the first operand to zero, or subtracting it from zero.

  8. Enjoyable read. One point of correction though :- I think it’s inaccurate to say the computation of sin and cos is similar to the application of a rotation matrix. What it really is is a truncation of a power series to the linear terms only for cos and to the linear terms plus an approximation of higher order terms for sin (this achieved by using the new value of cos in computing the new value of sin). You can see this if you do a maclaurin series expansion of e^(jd) and multiply that by (cos t + jsin t). This multiplication is a rotation of the current c,s value (cos t + jsin t) by angle d, assuming d is small. The new cos value is the sum of real terms and the new sin value is the sum of imaginary terms in the multiply expansion.

  9. Would Clive Sinclair and Nigel Searle have had access to a machine that could emulate the TMS0800 ? With a masked ROM they would have had to be incredibly confident to commit to production. An astonishing design and astonishing reverse engineering.
    PS: Has anyone else toggled the power switch on the sim and seen it boot ?
    That’s lovely.

  10. Unbelievable in 1974, now +1 some 39 years later. Well done to Clive Sinclair and Nigel Searle for the design and to Ken Sherriff for lifting the lid. It’s about time.
    An astonishing bit of code and top-rank reverse engineering, surely an inspiration to us all. Since the TMS0800 has a masked ROM, did they have an emulator, a development chip with an outboard ROM or did they audaciously commit to silicon ?

    Thank you Ken and well done. Did anyone else toggle the power switch and see the Sim boot ? Absolutely gorgeous.

  11. That’s a great article. I still have my Sinclair Scientific. It still works too, despite an occasionally troublesome on-off switch (a standard feature with that style of Sinclair calculator).

      1. The short answers are No and No. The coding, which was the first of only two coding jobs I ever did except for student exercises, took place over several months. TI had a simulator running on a mainframe in Dallas which I accessed from Houston on a two- or three-week visit in 1973, and from London periodically via a very slow satellite link. My first attempt – which may have taken “only a few days” – used twice as much ROM as was available. Toward the end, reducing the code became incredibly difficult; I was spending many days – and nights – searching for ways to reduce the code by even a single instruction.
        Of course, it would have taken less time overall if Clive Sinclair hadn’t got me working on several other projects at the same time. Happy days!

        1. I’m glad you’re here Nigel. Can I add your comments to my web page? And do you have any other interesting stories about the Sinclair Scientific? The algorithm for log seems particularly clever; how did you come up with it?

    1. Nigel, one historical detail would be very interesting to know: had you come across Minsky’s circle drawing (sincos) trick in the HAKMEM memo, or elsewhere, or independently discovered it?

      1. In mid-1972, Clive Sinclair started a project to develop a single-chip scientific calculator from scratch. I was hired to work with the chip’s hardware designers, specifying the instruction set, writing the code and deciding how much RAM and ROM were needed. This project, which was partially funded by Bowmar, was eventually abandoned in 1973, after we figured out we could utilize the TI chip.
        Clive was aware of the CORDIC algorithms used by H-P, but right from the start he had the idea to use the simpler, more compact – but slower – process for the trigonometric functions that was eventually implemented in the final product. Clive was a very good mathematician and it is quite possible that he discovered the process for himself. He also read technical and scientific literature extensively, but I doubt that he was aware of Minsky’s work. If he got any help from an outside source, it was probably from “Handbook of Mathematical Functions” (Abramowitz and Stegun, eds.) It was our Bible.
        My memory of the origins of the log function algorithm is less clear. I think the basic idea came from Clive, but was not as fully formed as the idea for the trig calculations. I did not rely on any outside source for whatever contribution I may have made to the algorithm, and if the idea was suggested to Clive by anyone else’s work it was probably something he read in the Handbook.
        I wish now that I had kept notes.

    2. Nigel, amazing stuff. You mentioned somewhere that this was one of two calculator firmware projects you did while at Sinclair. Was the other one the June 1975 Sinclair Scientific Programmable, the one with the green VFD display and the Oxford case ?

  12. I’m obviously missing something with the trig functions given, but they seem very wrong?
    Like, let’s say you want to compute cos(0.002) so that you only have to do two iterations.
    The article states that to rotate by 0.001 radians using the sin and cos of a starting angle, you just need to do the following:

    C = C – S / 1000
    S = S + C / 1000

    With C and S initially seeded to 1 and 0.0005, the iterations for 0.002 radians would seem to go:

    C = (1 – 0.0005) / 1000 = 0.0009995
    S = (0.0005 + 0.0009995) / 1000 = 0.0000014995
    C = (0.0009995 – 0.0000014995) / 1000 = 0.000000998
    S = (0.000000998 + 0.0000014995) / 1000 = 0.0000000024975

    Maybe the division by 1000 is supposed to be preceded by a multiplication or something? I’m not a mathematician. I’m just trying to walk through the algorithm and understand it.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.