Don’t Panic if any of the terms on this page are unfamiliar to you, because everything is explained in our book How Computers Do Math, and by the time you’ve read this little scamp you’ll be an expert.

The DIY Calculator is based on a very simple microcomputer system comprising a central processing unit (CPU), some memory, and some input and output (I/O) ports (these ports allow the system to “talk” with the outside world). The CPU itself is very straightforward and easy to understand: it has an 8-bit data bus and a 16-bit address bus; it contains a small number of simple registers like an accumulator, index register, and stack pointer; and it supports a very simple instruction set along the lines of ADD, SUBTRACT, SHIFT, ROTATE, AND, and OR.

Now, here’s the clever part. Instead of implementing our microcomputer system as a real (physical) board, we created it as a "virtual machine" that runs on a standard personal computer (an IBM-compatible PC running Windows® 2000 or Windows XP). This virtual system comes equipped with an assembler and a variety of diagnostic tools, such as a CPU Register Display, a Memory Display, and .... the list goes on.

The DIY Calculator also features a virtual calculator front panel with buttons, lights, and a pseudo-liquid crystal display (LCD) as shown below. This front panel is “connected” to the virtual computer via its input and output ports.

The main DIY Calculator interface

During the course of How Computers Do Math, we learn how to create software routines that detect when the various buttons are pressed, input decimal numbers and convert them into the binary representations used by the computer, perform math operations on these numbers, and then convert them back into decimal values to be presented on the main display.

First we learn about the binary and hexadecimal number systems, and then we learn a little about computers and calculators and perform some simple experiments with the DIY Calculator. Next we are introduced to some fundamental computing concepts such as the use of the index register, the stack, and subroutines. Along the way we gain familiarity with the assembly language used to create programs for the DIY Calculator.

As we proceed through the book, we create a simple four-function (add, subtract, multiply, and divide) calculator program that treats all values as 16-bit integers. Although it is fun to see this calculator perform its magic, we also discover the limitations associated with our 16-bit number representations. Thus, in the More Cool Stuff area in this website, we introduce more sophisticate representations such as fixed-point and floating-point.

And in addition to all of the above, we’ll discover lots of interesting snippets of information, such as the origin of the math symbols we use like +, -, x, /, and =.