
Classic Calculator Was Reverse Engineered from the Bare Metal - samizdis
https://spectrum.ieee.org/geek-life/hands-on/this-classic-calculator-was-literally-reverse-engineered-from-the-bare-metal
======
thaumasiotes
> The Sinclair Scientific was able to reduce complexity by using reverse
> Polish notation, in which mathematical operators come after the numbers they
> are operating on—for instance, “5 + 4 =” becomes “5 4 +.”

This is a great example of a place where you shouldn't use punc-quote
formatting. There is no . key on the calculator, but that's not obvious while
you're reading the article.

~~~
Mathnerd314
I found an old printer's manual a while back. The original typesetting
guideline was to put the quote and the period in the same column, one above
the other. This evolved to punc-quote on typewriters.

So I blame proportional fonts for their missing ligatures. :-)

~~~
paulgerhardt
Oh this is delightful. Can you share the reference if you have it still?

~~~
Mathnerd314
It is mostly the MLA handbook, [https://style.mla.org/punctuation-and-
quotation-marks/](https://style.mla.org/punctuation-and-quotation-marks/) and
[https://style.mla.org/the-placement-of-a-comma-or-period-
aft...](https://style.mla.org/the-placement-of-a-comma-or-period-after-a-
quotation/).

I guess I misremembered. The old reference from the 1800's is
[https://babel.hathitrust.org/cgi/pt?id=hvd.hx521x&view=1up&s...](https://babel.hathitrust.org/cgi/pt?id=hvd.hx521x&view=1up&seq=175),
he clearly puts the quotes on the outside too.

------
barbegal
Ken Schirriff's blog has a much more detailed and interesting explanation
including photos of the die that were used to reverse engineer it.
[http://files.righto.com/calculator/sinclair_scientific_simul...](http://files.righto.com/calculator/sinclair_scientific_simulator.html)

~~~
leni536
> How can sine and cosine be computed efficiently in a calculator that has a
> hard time even doing multiplication? The trick is to do repeated rotations
> by 0.001 radians until the desired angle is reached.

Genius!

------
Qasaur
Somewhat off-topic, but why does the IEEE (a non-profit) have annoying ads on
their site? I'm not using an ad-blocker and as soon as I clicked the link I
was bombarded by one big half-page ad and a bunch of other ads that are
irrelevant to the content of the article.

I would have thought that their _very_ expensive membership fees and
article/publication fees would have covered their operating expenses.

~~~
matheusmoreira
> I'm not using an ad-blocker

Why not? The advertising is never going to stop unless _everyone_ blocks it.
Content blockers should come pre-installed with all browsers. Ideally, they
should be fully integrated features instead of mere extensions.

That's the only way for browsers to still retain their status as user agents.
Browsers are supposed to act on _our_ behalf by showing us the information we
want to see. They aren't supposed to show us advertising noise for someone
else's benefit.

> I would have thought that their very expensive membership fees and
> article/publication fees would have covered their operating expenses.

It's not about covering operating expenses. Memberships revenue + advertising
revenue will always be greater than memberships revenue alone. It's an easy
choice for them to make. Why would they actively choose to make less money
than they could be making?

This advertising noise will never disappear on its own. We need to actively
get rid of it. We need to make it so that advertising is a waste of money for
companies. That's the only way to make them stop.

------
barbegal
The patent
[https://patentimages.storage.googleapis.com/0d/b2/87/7f219f3...](https://patentimages.storage.googleapis.com/0d/b2/87/7f219f38ca9899/US3934233.pdf)
for the chip this calculator was based on (the TMS080x) is a real work of art.
If you know how to make a transistor and a seven segment display, you can
build yourself a fully working calculator with the information in the patent.

The architecture is truly odd, using 44 bit registers (11 x 4-bit BCD) and
11-bit opcodes. It is more like an electrical abacus than a microcontroller.

~~~
kens
Most patents are worthless for learning anything, but Texas Instruments has
some remarkably useful patents. That one, in particular, is a 61-page complete
description of the calculator hardware with detailed schematics, as well as
the software in flowchart and assembly form and the chip's instruction set.
The patent has enough information to completely simulate the calculator (which
I did: [http://righto.com/ti](http://righto.com/ti)). This patent was clearly
written by the engineers and not the lawyers.

The funny thing is that what the patent actually claims is an obscure
technique for connecting the ground lines in the calculator's ROM. In other
words, almost all the detailed text in the patent is irrelevant to what is
actually patented.

~~~
barbegal
Thanks Ken, it's a great simulator. Is there any way others could write code
for this simulator and play around with it as opposed to just running the
original code?

And what are the best and worst features of this hardware architecture? Was
there any little thing you think the designers should have done to improve it?
Or was there something genius about it?

~~~
kens
If you want to hack on the calculator, the code is on github:
[https://github.com/shirriff/TICalculatorJSSimulator](https://github.com/shirriff/TICalculatorJSSimulator)

As far as the architecture of the calculator, it's kind of amazing that they
were able to build a calculator chip at all, given the state of IC technology.
The architecture is highly tuned to calculators, rather than being general-
purpose. For instance, a "digit scan" register cycles through 10 scan lines to
illuminate each digit. At the same time, it scans 10 rows of the keyboard.

Another interesting thing about the calculator chip is it has 11-bit opcodes.
Powers of two are so ingrained in us that it seems bizarre to have 11-bit
opcodes. But old computers often had random word lengths. The calculator's
instruction set is very low-level, more like microcode than a "real"
instruction set.

------
drfuchs
Why can't they mention "CORDIC" so that interested readers can find out the
cool details about how to actually calculate "... trigonometric functions by
repeatedly rotating an initial vector until the target angle was reached..."
using only fixed-point add, subtract, and shift?

~~~
Someone
Nitpick: this calculator uses only one of the core ideas of CORDIC: that one
can compute sines and cosines by repeated rotation. It doesn’t use the other
core idea that you can approximate any angle by successively halving each
step.

It doesn’t do the latter because of lack of memory to implement it in.
[http://files.righto.com/calculator/sinclair_scientific_simul...](http://files.righto.com/calculator/sinclair_scientific_simulator.html):

 _“How can sine and cosine be computed efficiently in a calculator that has a
hard time even doing multiplication? The trick is to do repeated rotations by
0.001 radians until the desired angle is reached.

[…]

Other calculators use algorithms such as decimal CORDIC that are much faster
and more accurate, taking time proportional to the number of digits.”_

------
amelius
Here's someone who rebuilt the device with modern parts:

[https://hackaday.io/project/91895-sinclair-scientific-
calcul...](https://hackaday.io/project/91895-sinclair-scientific-calculator-
emulator)

------
samizdis
> ... the replica reproduced its behavior, by using an emulator running
> firmware that had been reverse engineered by _visually examining the metal
> of an original processor_.

------
roelschroeven
> The Sinclair Scientific was able to reduce complexity by using reverse
> Polish notation, in which mathematical operators come after the numbers they
> are operating on—for instance, “5 + 4 =” becomes “5 4 +.”

It's not really RPN though. RPN lets you write "2 × (5+4)" as "2 5 4 + ×", but
the Sinclair Scientific doesn't support that. It would have needed a stack for
that, which wasn't available. Instead each operation simply acts on the
previous result. You'd have to use "5 + 4 + 2 ×" instead.

Still very impressive how they managed to accomplish all that using that
simple TI chip and only 320 instructions.

~~~
ec109685
It’s not “5 4 + 2 x”?

~~~
duskwuff
That'd give you 54 x 2. You have to press + to delimit the initial value.

~~~
roelschroeven
Actually 5.4 × 2; for 54 you have to enter 54E1 (5.4 × 10^1).

------
ajnin
OT but it's a real shame the bubble LED displays used in those calculators are
not manufactured anymore. Something about the warm red glow and incandescent-
like filament look appeals to me. They are also very compact, it's
occasionally possible to find more recent bubble displays but quite bulkier,
and outrageously expensive.

------
Paperweight
The UI design of calculators is fascinating. Where do you put the buttons? TI
and friends have a randomish layout, let alone the TERRIBLE mobile calculator
apps.

(Self-promotion) I always wanted to design a calculator and finally got around
to it as a lockdown project - [https://ucalc.app](https://ucalc.app)

------
throwaway_pdp09
That is one strange calculator. It's like having a car with 3 buttons;
forward, backward and teleport.

~~~
Aardwolf
Forward, backward and rotate left.

~~~
anewdirection
If childhood taight me anything, the minimum is just 2 buttons. Forward,
reverse-left. Simple, usually effective, and maddenly oversimplified. I think
I liked the one that only sent forward more, but it of course required a
track.

People forget simple things like steering servos were not available to most
kids until the 90s injection molding explosion that is so ubiq today.

~~~
Paperweight
Weren't there single-button ones that would continuously drive forward unless
you pressed the remote control button, which would switch it to reverse-left?

So to "stop" you had to keep tapping the button.

------
fnord77
I was on a VPN and was getting http 418 from this server. Weird.

