I was looking at this emulator of a Intel 4004, and I noticed something with the RAM. It had something called "Status Chars". There were 4 of them per memory line and all were 4-bit numbers which could be set from 0-F. They didn't seem like they had any use to me, so I searched on Google to find answers, but I found nothing. They appeared on every single RAM chip on the emulator, and they didn't appear at all in the ROM. What are these "Status characters", and what is their purpose in the 4004 and other microprocessors?
[...] RAM. It had something called "Status Chars". There were 4 of them per memory line and all were 4-bit numbers which could be set from 0-F. [...] They appeared on every single RAM chip on the emulator, and they didn't appear at all in the ROM.
The 4004 can address 16 ROMs and 4 RAM chips. When addressing a ROM port 4 bits are used to indicate the ROM. With RAMs two are used to address the chip, while the two remaining select the register (*1)
What are these "Status characters",
They are simple RAM cells, like all the others. Except, they got kind of an immediate addressing mode.
- To access any of the 'main' words the address (chip/bank in R and address in R+1) had to be set with the SRC instruction and fetched/written with RDM/WRM. For accessing another word the address had to be set again and issued with a SRC instruction.
LDM 0 / 0 -> ACCU DCL / Select Data Bank 0 FIM 2 4 / Load register pair 2/3 with address for Chip 0 Register 0 Word 4 SRC / Set address RDM / Read word 4 into ACCU ... WRM / Write the same word ... INC 3 / Increment Word address SRC RDM / Read word 5
- To access the 'status character' only the chip/bank part had to be set via SRC, while the individual words were addressed by specific instructions, resulting in faster access
LDM 0 / 0 -> ACCU DCL / Select Data Bank 0 FIM 2 0 / Load register pair 2/3 with address for Chip 0 Register 0 Word x SRC / Set address RD0 / Read status character 0 ... RD1 / Read status character 1 ... WR0 / Write status character 0
and what is their purpose in the 4004
Primary to work as fast, direct accessible scratch pad and/or markers for the value stored in a (RAM) register. The 4 status characters of a (RAM) register addressed can be accessed direct without setting up and issuing an SCL instruction.
Like with any RAM it's up to the programmer what to use it for. The Busicom 141PF, the first device using a 4004, had two RAM chips for a total of 8 registers of 20 words each. While register 0 was used as keyboard buffer, the other seven stored numbers.
- Special Character 0 held the sign in bit 0, while
- SC1 held the position of the decimal point, essentially the decimal exponent (*2).
- SC2 and SC3 of some registers held various flags,
So long story short, the RAM was used as 7 registers, one keyboard buffer and 32 words of other RAM.
and other microprocessors?
They are specific to the 4004
At that point one may ask why this strange organisation. After all, there were enough opcodes to address a second set of 16 word registers instead of fiddling with normal RAM and 'special' RAM.
For one such a chip would have been way to complex (and expensive) at the time. The 4002 RAM had already a transistor count similar to the 4004 CPU. Doubling that was simply unrealistic.
For the intended use as calculator the main need for RAM comes from number storage, not so much from runtime variables and alike. The Busicom 141PF uses only 8 words to store other information then numbers, most of them holding just one or two valid bits.
Of course Intel could have gone for a straight 4x16x4 RAM instead, but then calculators would have had to limit precision to less than 16 digits (*3) or use a second RAM chip.
By implementing full 16 digit storage per register and 4 word scratch in one device a simple calculator could be made with a single RAM chip. Further lowering entry cost.
*1 - The description from the Wiki about them being addressed instead of ports is misleading, as for one a different instruction is used, but even if assuming, it's not instead of ports but instead of ROM addresses.
*2 - Except only positive - the machine was intended as business device, a task in no need for real small numbers.
*3 - Busicom 141PF used only 14, but that's due the printer only offering 15 positions.
4002: 40-byte RAM (80 4-bit data words), and one built-in 4-bit output port; the RAM portion of the chip is organized into four "registers" of 20 4-bit words:
16 data words (used for mantissa digits in the original calculator design), accessed in a relatively standard manner, and
4 status words (used for exponent digits and signs in the original calculator design), accessed using I/O type commands in place of the ROM's input channel.