Introduction

The story of the Intel 4004 microprocessor chip starts with a Japanese company known as Busicom (originally Nippon Calculating Machine Corp.) As described in this Wikipedia article, Busicom hired Intel in 1969 to produce an integrated circuit chip-set for a line of electronic printing desk calculators. As stated in that article:

  • Intel’s Ted Hoff was assigned to studying Busicom’s design, and came up with a much more elegant, 4 ICs architecture centered on what was to become the 4004 microprocessor surrounded by a mixture of 3 different ICs containing ROM, shift registers, input/output ports and RAM.

That article describes how a 1971 price renegotiation led to Busicom providing Intel with cross-licensing rights to the 4004 chip-set design. (We can assume that Busicom held the original exclusive rights under a work for hire contract provision.)

Courtesy of Intel, here is a composite layered image of the photo-lithography masks used to manufacture the 4004. (Note that these masks were created manually on drafting boards.)

Intel 4004 chip masks

The Wikipedia Intel 4004 article provides additional details on the design of the CPU and its support chips.

As part of the Intel museum project, here is a page that describes the integrated circuit advancements since the days of the 4004: The Story of the Intel® 4004

CPU Structure

The Intel 4004 was based on a 4-bit word size, also known as a character; this is suitable for storing a single binary-coded decimal digit. Some of the circuitry combined successive 4-bit words into 8-bit instructions.

The CPU contained 16 4-bit registers. These registers could also be paired and treated as 8-bit values; these paired 8-bit register values supported an index-register base/offset addressing scheme, so that effective memory addresses were 12-bits.

Memory access made a sharp distinction between random access memory (RAM), and read-only memory (ROM).

  • RAM was limited to 1280 4-bit words (640 8-bit bytes); it was used for a limited subroutine call stack and to emulate an extended set of registers, such as a keypad keystroke buffer and the calculator’s memory store/recall feature.
  • ROM contain the assembly language instructions, and was able to address up to 8192 4-bit words (4096 8-bit bytes). The contents of the ROM chips in the shipping calculator product were determined by a metal mask layer that was imprinted on the chips during the manufacturing process. (During prototype development, write-once PROM chips were likely used while the software was being debugged.)

History Preservation Activity

The physical context of the original Intel 4004 application appears in these images: Busicom 141-PF Printing Calculator Engineering Prototype, 1971

The web site www.4004.com contains several artifacts and links to current preservation and simulation efforts related to the Intel 4004.

The original ROM chip contents for the Busicom 141-PF calculator were read, disassembled, and annotated by Tim McNerney and Fred Huettig in collaboration with the Computer History Museum in 2005. The results of their efforts are available here: Annotated Busicom 141-PF software.

Here is a fascinating audio recording of Tim McNerney’s talk at 35th Anniversary event (13-Dec-2006) describing the reverse-engineering of a surviving Busicom calculator. (Here is the text transcript.) Mr. McNerney closes his talk with the notion that the designs of early computers, such as the Intel 4004 microprocessor, serve as valuable case studies that can enlighten modern students of computer engineering.

Busicom 141-PF Calculator Software Structure

As mentioned in Tim McNerney’s talk, the 12-chip design provided by Busicom to Intel in their original manufacturing request implemented a set of calculator-specific operations using custom logic circuitry and a limited ROM control store. The Intel team instead proposed a 4-chip design with the Intel 4004 general purpose 4-bit CPU driven by a somewhat larger ROM program store.

In order to preserve logical aspects of Busicom’s design, the Intel team used the 4004 assembly language to program a software interpreter that implemented Busicom’s original calculator operations as pseudo-ops.

Each iteration of the pseudo-op interpreter started with a keypad matrix scanning loop to wait for and detect a keypress, then dispatched to a pseudo-op routine determined by the keypress. The pseudo-op interpreter acted as a finite state machine in response to successive keystrokes on the calculator keypad.

Here are the internal states, as described in the annotated disassembly listing:

;The main states of the state machine are stored in RR.S2, DR.S2, CR.S2 and SR.S2.
;These have only limited values, which represent
;the following situations:
;
;RR.S2=0 - new number is entered (or some operation is ended, 
;          and the result can be used as a new number)
;RR.S2=1 - last operation was multiply or divide
;RR.S2=8 - last operation was addition or subtraction
;
;DR.S2=0 - no started multiplication or division 
;          (may mean DR is divided by default)
;DR.S2=3 - started multiplication (DR is multiplied)
;DR.S2=4 - started division (DR is divided)
;DR.S2=8 - default division with constant value in CR
;DR.S2=B - started multiplication with constant value in CR
;DR.S2=C - started division with constant value in CR
;
;CR.S2=0 - digit entry is not started yet
;CR.S2=1 - started digit entry with digit point
;CR.S2=8 - started digit entry without digit point
;
;SR.S2=0 - no overflow
;SR.S2=1 - overflow occurred

All arithmetic operations were performed using binary-coded decimal (BCD) routines, similar to those described in my previous article Representation of Data Types in ESI-X on the PDP-8. All calculations were treated as scaled integers, with an implied fixed number of decimal places set by a sliding switch above the calculator keypad.

Tim McNerney made passing mention in his talk about a square root operation. This was an optional feature that was included in higher priced models of the Busicom calculator. An additional calculation routine was needed to perform square roots, and this required a 5th ROM chip to be added to the normal 4 that contained the standard software. (At an estimate cost of 5 cents per byte in 1969, or about 25 cents per byte in 2014, the cost of this extra ROM chip was not insignificant.)

The full details of the square root algorithm are provided in the annotated disassembly listing comments. Here is the overview from those comments:

;Mathematical background:
;
;At first, let us think in the set of integer numbers only.
;The task is to find a suitable "p" to certain "N", where
;
; (p+1)*(p+1) > N >= p*p.  We can say then, that SQRT(N)=p.
;
;E.g. SQRT(5936123) would lead to 2436, as 2437*2437=5938969 > 5936123 >= 2436*2436=5934096.
;
;It is easy to see, that stealing 2 digits from the end of "N" results
;stealing one digit from the end of SQRT(N):
;
; E.g. as SQRT(5936123)=2436, then SQRT(59361)=243, SQRT(593)=24 and SQRT(5)=2.
;
;The square root is guessed digit by digit from left to right in the reverse logic to the previous rule.
;For calculating the sqrt for a big number, at first digits are "removed" pair by pair from the end,
;e.g. 5936123 leads to 5, then the calculation is started from the "simplified" number (from 5).
;When the square root is already known for it ("half result"), 
;then the next two digits of "N" are taken (93)
;and the next digit of the square root of 593 is "guessed" based on the already known "half result".
;This algorithm is repeated till the end of the "N" by taking the removed digit pairs (61 and 23). 

Printer Driver Routine

The Busicom calculator had no digit display; all entries and results were printed onto a roll of paper. The printer mechanism had a spinning drum equipped with 18 columns having 13 characters on each. Columns 1 thru 15 had cast symbols for the digits 0 thru 9, two copies of a decimal point, and a minus sign. Columns 17 and 18 each had customized symbols for various operations such as + – X / and the square root symbol, among others.

The printer drum spun behind the paper, and an inked ribbon was positioned in front of the paper behind a set of hammers. The inked ribbon had both black and red ink in separate stripes; it could be raised and lowered so that negative results could be printed in red ink.

The printer driver routine kept track of which row of the constantly spinning drum was next to arrive under the hammers. The routine loaded an 18-bit sequence of 1’s and 0’s representing one row on the printer drum into two Intel 4003 shift register support chips cascaded end-to-end. The hammer mechanism was triggered, causing the hammer for any column with a 1 bit to strike the ribbon against the paper. Once all drum rows had cycled under the hammer, the routine activated a signal bit to advance the paper.

Conclusion

As so elegantly stated by Tim McNerney, the preservation of computer hardware and software designs from past decades provides intriguing and enlightening case studies that can guide our future designs. Creative solutions were devised by small agile teams to meet their design goals while observing significant constraints in cost, speed, and complexity.

The Intel 4004 was a foundational microprocesser that ultimately bred a long line of successors with Intel model numbers such as 8008, 8080, 8088, 8086, 80186, 80286, 80386, i486, and so on.

Advertisements