13 ms·
Reversing Sinclair's amazing 1974 calculator hack - half the ROM of the HP-35
- ChuckMcM 13y agoNicely done, especially compared to the fits that HP went through trying to figure out how they could prove or disprove that all 11 digits of their calculation were correct.
- joezydeco 13y agoI wouldn't call them "fits", really. 40 years ago these calculators were looked upon with a bit of skepticism. Engineers that were used to seeing the log tables with their own eyes and hand-manipulating slide rules were being asked to trust the results coming out of these calculators. And lives depended on it, really. If you were a civil engineer designing a bridge and you needed to be absolutely sure the numbers you were using were accurate to 7 places and totally correct, would you suddenly put all your faith in this small brown box with no way to examine the inner workings? HP went through a lot to build that trust and it was rightly earned. HP's reputation for building solid accurate calculators kept that business going for decades to come.
- WalterBright 13y agoTrusting the numbers coming out of a calculator was ALWAYS a bad idea, especially if lives depended on it. It wasn't just the calculator making a mistake - you could have made a mistake keying in the numbers. This is dealt with by: 1. running the results through the inverse equations to verify that you get the inputs back again 2. calculating the results using an independent method to verify them 3. having a different group of people independently check your numbers 4. have your results pass a "reasonableness" test, i.e. do they make sense 5. put the resulting design on a test rig and verify the numbers experimentally How do I know this? I worked on critical flight control systems for Boeing. Any engineer who just punches numbers into a calculator and bets lives on the results ought to be fired.
- wtallis 13y agoThese days, we can also have our calculators keep track of the units associated with a quantity, which helps greatly with sanity-checking. If the units come out wrong or mis-match anywhere in the calculation, you'll know immediately.
- WalterBright 13y agoIt's nice to have extra checks, but that changes nothing about what I said. If you are making designs that lives depend on, it is not HP's responsibility, it is YOURS and you should be using the techniques I outlined. I'm sorry to be so blunt about this, but I feel strongly about it. I too often run into engineers that either argue that they can design a perfect system that is not subject to human error, or they try to shift responsibility onto other people or organizations.
- WalterBright 13y agoBTW, I think every engineer should watch the series on the Smithsonian channel "Air Disasters". Each episode chronicles a particular disaster, and then painstakingly goes through what went wrong and how the problems were fixed. One can learn a lot about systems design from these case studies on how and why things go wrong.
- agumonkey 13y agoThanks for this (and the others posts). Any other recommendations (papers or videos) ?
- derefr 13y agoIn your opinion, if doing step 5 is cheap enough, do you still need 1-4? (That is, is it "okay"--in a pragmatic sense--to have sloppy thinking, if you can just throw numbers at the wall to see if they stick?)
- WalterBright 13y agoDoing 5 is rarely cheap enough. It's well known that the earlier in the process errors are fixed, the cheaper they are.
- keithpeter 13y agoA very old school surveying teacher (head of department as it happens) wasn't entirely convinced about calculators in the late eighties. I showed him how to get an extra decimal place of seconds of arc by subtracting the whole number of degrees. The real sticking point was getting a real arctan2 function (returning the angle in the range [0,360]). He really liked some BBC Basic programs I hacked up. Fun times.
- ajross 13y agoThe bit that is probably most striking to modern eyes is the data representation. With 320 instructions there's simply no room for the "obvious" code to translate to and from a display representation. So everything was stored in BCD and operated on one (decimal!) digit at a time using a 4-bit ALU.
- alayne 13y agoI was under the impression that BCD was commonly used in calculators. I know that my HP 48 used BCD and was able to address 4 bit nibbles.
- kens 13y agoYou're right that BCD is very common for calculators. BCD was also commonly used in microcomputers, since you save all the binary-to-ASCII code for I/O. This is why x86 has a bunch of BCD instructions like AAA (ASCII adjust after addition), which was important enough to be a single-byte opcode. The 6502 is notable for its highly-efficient and patented (https://www.google.com/patents/US3991307 https://www.google.com/patents/US3991307) decimal arithmetic mode. I'll write up its interesting circuits sometime. One consequence of the patent is the processor in the NES video game is a 6502 clone that lacks decimal mode.
- Scaevolus 13y agoI had thought the 2A03 didn't have BCD to save silicon-- but apparently they just crudely disabled it by removing 5 transistors[1]! Would Ricoh's second-source 6502 license have been more expensive if they included BCD? [1] http://www.visual6502.org/wiki/index.php?title=6502DecimalMode#Decimal_mode_and_the_NES.27_RP2A03G http://www.visual6502.org/wiki/index.php?title=6502DecimalMo...
- ck2 13y agoI am not sure what is more amazing, the original creation or the cleverness of the person who figured out everything they did. I guess the original creation but wow, now that is a dedicated hobbyist. The Visual 6502 group enjoys dissolving old chips in acid, photographing the die, and reverse-engineering them. Wow!
- deleted 13y ago[deleted]
- arbuge 13y agoThe Visual 6502 group enjoys dissolving old chips in acid, photographing the die, and reverse-engineering them. Unfortunately (or not, depending on your perspective) it's not just the Visual 6502 group that enjoys that. Any leading chip in the marketplace these days is almost immediately reverse engineered in this way. I haven't been in the chip business for a few years but I recall a company which offered this as a complete service - they'd send you detailed circuit schematics and so forth.
- pdknsk 13y agohttp://www.chipworks.com/ http://www.chipworks.com/
- arbuge 13y agoYeah, that's the one.
- beambot 13y agoFlyLogic used to do some awesome teardowns too: http://www.flylogic.net/blog/ http://www.flylogic.net/blog/ If you go back through their blog posts, they have some cool techniques for bypassing "security" metal meshes to read out the secure FLASH/ROM sections of chips. IIRC, one of the guys behind FlyLogic was involved in the high-profile reverse engineering of satellite receivers (ie. satellite pirating).
- 13y ago
- sirsar 13y agoThis is great. Scientific calculators usually provide constants such as e and π but there was no space in the ROM for these constants. The Sinclair Scientific used the brilliant solution of printing the constants on the calculator's case
- rarw 13y agoThat's gotta be the hackiest hack ever - write it on the outside. Genius.
- rarw 13y agoReverse Polish Notation - sounds like the punch line to a really bad math joke
- revelation 13y agoThe joke has been going on for quite some time now - Lisp and related languages use Polish Notation everywhere. (The main benefit is that (R)PN is parenthesis-free, so it makes it easier for a calculator to process expressions with multiple operators. The use in programming languages is nonexistent but to make clear that +, *, .. are just like any other function call, where you would naturally use polish notation.)
- Scaevolus 13y agoNot nonexistent-- there are many stack-oriented programming languages[1], of which Forth is the most famous. There's even a "Reverse Polish Lisp" on HP calculators! [1] http://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Stack-based_languages http://en.wikipedia.org/wiki/List_of_programming_languages_b...
- revelation 13y agoSorry, I meant there is no benefit to using it in programming languages.
- Scaevolus 13y agoForth is arguably the best language in terms of expressive power/language complexity, though that's largely due to the denominator. It's a great choice for tightly constrained devices, though far fewer devices have such constraints now. The mental overhead of having to track stack-effects for each function makes it difficult to scale to large systems and maintain productivity, but if you're trying to eke every iota of power out of a chip with a tiny amount of ROM, it's hard to beat a direct-threaded (or token-threaded...) Forth.
- nealabq 13y ago
- rootbear 13y agoSo is 'reversing' a common lazy shorthand for 'reverse engineering'? The title confused me until I realized what it was about. Feeling like an old fart...
- ableal 13y ago"You might be surprised to learn that the calculator chip cannot perform multiplication natively. There's no floating point unit to multiply two numbers." Quite true. The sexy multiplier chips from TRW (http://en.wikipedia.org/wiki/TRW_Inc http://en.wikipedia.org/wiki/TRW_Inc. ) were still a few years off, and not intended for mere calculators. Same for the Intel x87 floating point co-processors (http://en.wikipedia.org/wiki/8087 http://en.wikipedia.org/wiki/8087). Nowadays the silicon real-estate cost for floating point math is trivial, and chip area is filled out with RAM cache for lack of anything better to do ...
- 6ren 13y agoUnfortunately, as calculator prices collapsed, so did Sinclair Radionics' profits, and the company was broken up in 1979 after heavy losses. He fought Moore's law, and the law won. But this whole thing reminds me of Woz's work in the first Apples. Why wasn't his genius work similarly wiped out? Soon after the Apple, there were dozens - hundreds - of new personal computer manufacturers. I think it's software. The value of a platform is what you can do with it. Software increases what you can do, therefore increases the value of the platform. There's increasing returns, so once it gets started, it gets harder and harder to stop. Branding is also important (Jobs), which is why the Apple eventually fell to the "PC" - because the strongest computer brand in the world for decades was IBM.
- WalterBright 13y agoVisiCalc on the Apple had a huge contribution to its success. It was the proverbial "killer app" that drove Apple II sales.
- lutusp 13y agoYes, that and Apple Writer. Full disclosure: I wrote Apple Writer.
- nogoodnik 13y agoThank you for writing Apple Writer. 1. I wrote most of my high school reports on it. 2. I once wrote a set of WPL programs to automate the generation of multiple-choice tests, and sold it for $50 to my uncle who was a physics teacher. 3. Apple Writer was the second program I disassembled from beginning to end (the first was Locksmith Fast Disk Copy), learning a lot in the process.
- lutusp 13y ago> Thank you for writing Apple Writer. You're welcome! I know this is a predictable remark, but I miss the good old days. The Apple II was so simple and understandable that I was able to write a program that played two musical notes at once (I called it the "Electric Duet"), in tune, and a fairly tolerable sound, even though the speaker was driven by a TTL output (meaning no analog level control). If the Apple II had had interrupts, my program would have stopped working. I know this because an Apple II successor supported a mouse, the mouse required an interrupt, and it ruined the performance of my program. Oh, I almost forgot -- Tom Clancy wrote "The Hunt for Red October" on Apple Writer.
- ivanbrussik 13y ago80085 thats my calculator hack
- AsymetricCom 13y agoWhat's more interesting than how the calculator works is how Sinclair was able to write the code for such a chip, which the article doesn't attempt to guess at. I wonder if he used some kind of boostrap on paper, looking at the algorithms.
- kens 13y agoI don't know about the Sinclair development specifically, but for the HP-35, they wrote a register-level simulator in software that let them develop the algorithms and single-step through for debugging. My favorite quote from the article: "Correcting a problem was a simple matter of changing a punched card or two." http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1972-06.pdf http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1972-06.pdf The article goes into a lot of detail on the HP-35 internals, so it's worth a look.
- deleted 13y ago[deleted]
- epo 13y agoNigel Searle, not Clive Sinclair, as it says in the 3rd paragraph.
- Zenst 13y agoIf you need to explain this too less geeky friends then telling them that this amount of storage is less than a single letter on a modern display. Which on a 32bit display at 12x12 you would be on 576 bytes (8 bits) and this is compared to a 320 11 bit word (320x11/8=440) 440 bytes. This makes chess on a 1k zx81 including display seem like bloat-ware now :). Nowadays we have more storage on the keyboard controller chips, heck the older ones during the 90's had 4 KB storage, so almost 10x more ROM alone to work with - for a keyboard.
- nwh 13y agoGiven that Sprite managed to get Linux booting on a hard disks processor [0], I'm increasingly aware that the embedded device we use are overpowered. Makes for some interesitng hacking though, I bet you could run a webserver on my washing machine. [0]: http://spritesmods.com/?art=hddhack http://spritesmods.com/?art=hddhack
- jordanthoms 13y agoI really wish someone would make a modern scientific calculator - Imagine what would be possible on a modern ARM processor. Even the new HP calculators use old ~70mhz ARM processors emulating the even older saturn HP48 code... You could build it on top of Android, and have the software be open-source while making money from selling the hardware (so you could run it on a touchscreen, but if you wanted a keyboard you'd buy the calculator).
- wtallis 13y agoProcessing power hasn't been a bottleneck for a long time. Even the 4MHz Saturn processors were able to do reasonably fast 3d wireframe graphing. The only reason graphing calculators and scientific calculators still exist outside of schools is because they can provide a specialized user interface: a physical keyboard with a layout designed around calculation tasks, and a software environment that is similarly optimized for that narrow range of use cases. Neither of those aspects benefits significantly from Moore's Law. Instead, they can only benefit from the complementary products that other gadgets have made commodity components: high-resolution displays, lithium-ion batteries, SoCs that replace ASICs and make features like USB and SD support free.
- goblinfoblin 13y agoThere are modern calculators: Mathematica, Matlab, and the most used: Excel For tasks that need to be done away from a computer sure a calculator is handy but that has rather dwindled down to basic calculations. Schoolwork sure calculators are great but I never needed more than my HP-48 and when I did it was usually an assignment meant more for MATLAB/Mathematica. Now for your point of building it on top of android, what I want is not another device but I want a new calculator built for android. Everyone has a smartphone these days why should I have to buy a calculator when I have a strong computer in my pocket. We just need an interface for smartphones and the appropriately strong (Programmable) back end. This looks nice but I don't have an iPhone https://itunes.apple.com/us/app/nd1/id368497993?mt=8 https://itunes.apple.com/us/app/nd1/id368497993?mt=8
- ghshephard 13y ago
- znmeb 13y agoWhile clever and inexpensive, the low speed and low accuracy of this device made it unusable. It was billed as "3-figure accuracy", but in fact it only got that on some cases. A bright undergrad or grad student could quickly uncover useful problems that it flat out couldn't solve. In short, it was a toy. Anyone basing one's academic grade on this thing was a fool. You really did have to spend the money for an HP-35, or the later Texas Instruments SR-5x calculators that were less expensive.
- Tloewald 13y agoI owned Sinclair's programmable scientific calculator from a few years later which was similarly "interesting". It had 36 program steps (vs. 72 for the HP65 iirc), so storage system, and only one memory. Each constant in a program counted as N+1 steps where N was the number of button presses were needed. So it taught me about multiply re-entrant code. I also owned a Sinclair ZX-80 (aka Timex) computer, later upgraded to a ZX-81 ROM with 16kB of memory. Overall, Sinclair's problem seems to have been going a little too far in the "worse is better" direction with every product.