Microprocessor 1971 Four Bit Arithmetic Unit Decimal Correction
# Build the Arithmetic Unit: Four-Bit Binary Addition With Decimal Correction
## 1. Make One Ripple-Carry Adder Serve the Accumulator
The Intel 4004 performs arithmetic through a four-bit ripple-carry adder connected to its four-bit accumulator, index registers, internal bus, and carry/link flip-flop. Each bit position adds one accumulator bit, one operand bit, and the carry arriving from the less-significant position. Its sum becomes the corresponding result bit; its carry advances to the next stage.
For bit position $i$,
The least-significant stage receives the existing carry/link value when an ADD operation requests addition with carry. The final carry leaving bit 3 is stored back in that flip-flop. Because the four stages are connected in sequence, a carry produced at the low end must ripple through intermediate stages before the high-order result is settled. This saves the extra circuitry of a wider or more elaborate adder while matching the four-bit word chosen in Step 2.
## 2. Recognize That a Valid Binary Sum Can Be an Invalid Decimal Digit
The adder itself is binary. If it adds decimal digits 7 and 8, it produces $1111_2$, which is the binary value 15. But a single binary-coded-decimal digit may use only $0000_2$ through $1001_2$ for decimal 0 through 9. The patterns 1010 through 1111 are valid binary numbers but invalid decimal-digit codes.
The 4004 resolves this with a separate DAA instruction—Decimal Adjust Accumulator. According to the MCS-4 manual, DAA increments the accumulator by 6 when the carry/link is already 1 or when the accumulator contains a value greater than 9. Adding six skips the six unused four-bit patterns and produces the correct low decimal digit, with carry representing the next decimal position.
The corrected accumulator is $0101_2$, decimal 5, and carry/link is 1: together they encode decimal 15. If the original binary addition already overflowed four bits, carry/link requests the same correction and remains the decimal carry even when the correction itself does not generate another overflow.
## 3. Combine General Binary Hardware With Calculator-Specific Support
The arithmetic unit illustrates the architectural compromise at the center of the 4004. Its physical adder remains a general binary circuit, useful for arithmetic, counting, incrementing addresses, and other state transformations. Calculator-oriented decimal behavior is supplied by control and a dedicated adjustment operation rather than by replacing the core with a decimal-only adder.
This also clarifies the decoder's role from Step 4. An ADD opcode selects the accumulator, the addressed register, carry/link, and the adder path. A later DAA opcode selects the correction behavior, including the special conversion logic described in Intel's block-level documentation. The same gates and registers perform different work because stored instructions activate different control paths.
Step 5 has built the processor's computation path, but instructions still need a persistent source outside the CPU. Step 6 will place the program in a separate 4001 mask-programmed read-only-memory chip and contrast that stable instruction store directly with the refreshing, writable DRAM cell built in the 1968 series.