Introduction to the COSMAC 1802 Register Layout
The COSMAC 1802 Register Layout is a bit different from other processors. If you are used to the 6502, for example, you will find the addressing is much more indirect. For example, the P register is not the program counter. It simply points to which register we want to use as the program counter. In this post, we’ll go through the processor’s registers. This will include an 8 bit register and sixteen registers which are 16 bits each. Additionally, you have five registers which are 4 bits each, and a couple processor flags. This will be the first of a series of posts for the COSMAC 1802 processor.
COSMAC stands for Complimentary Symmetry Monolithic Array Computer. It was ideal for the Galileo spacecraft that explored Jupiter launched in 1989. There is no minimum clock frequency. It will run on low power. Hobbyists would build the COSMAC Elf in order to learn more about these processors.
I’m just starting out with this processor, so if you find errors in this document, or suggestions, please post in the comments below. Additionally, I will make corrections and clarifications to this document as I get more experience with the processor. For now, I’m just using the 1802UNO code on a Kim-Uno build. I did order an 1802 Training kit from Ebay, which I’m hoping will arrive very soon!
Tom Pittman created a good course that you can go through as well for learning more about the 1802.
Sixteen Bit Registers
There are 16 of these sixteen bit registers. R(0) through R(F) in Hex. In decimal, this is R(0) to R(15). For the rest of this post, all notation will be in Hexadecimal.
Being 16 bits each, these are ideal for storing address locations such as the program counter. You can also use them to store data for math functions. Remember there is a lot of indirect addressing in the 1802. For the most part, we decide what we want to use these registers for. We simply point to a register as the program counter, indexing, etc. Typically, we use R(0) for DMA, R(1) for the interrupt vector, and R(2) for the stack pointer. R(3) would be the general program counter. If you use call and returns, then the suggested usage is with R(4) and R(5) respectively. R(6) by standard is a “scratchpad” register. Note: on the CDP 1802 Microprocessor Kit, R(0) is the Program Counter by default.
Four Bit Registers
The COSMAC 1802 has five registers which are 4 bits each. These can store information from instructions, the program counter, or indexing.
It’s important to realize this is not the program counter. It simply contains 4 bits that point to a 16 bit register (above) which is the program counter. The values can be 0 to F.
Being used to the Kenbak-1, I typically think of X for Indexing. X points to a register that we use for math and other logic instructions. As I said before, X is not the register we actually use for these instructions. Although it’s involved in the instructions, it simply points to a register that we use for these instructions. For example, when we set X to register RC, we only need to load a value into the accumulator (D Register). After that, we can simply use a stand-alone ADD statement. Since we already have a value in the accumulator, and X already points to RC, the COSMAC knows what two registers to perform the addition on. The result will be in the D register.
I and N Registers
The processor uses I and N to store opcode information. For some instructions, N will contain the register number that contains a memory location that we need to look at. For the most part, we don’t concern ourselves with these registers themselves. However, the processor does use these registers for it’s operations.
Eight Bit Registers (D and T)
In the COSMAC 1802, the D register is the 8 bit accumulator. This is similar to the “A” register in other machines such as the Kenbak-1 and 6502 systems. Most of your math functions will use this register for performing math and logical functions.
The T register is mainly just used by the processor itself as a temporary storage location. As programmers we don’t have much use for this register when we start out. However, once you start learning more about interrupts, you will better understand how the processor utilizes this register.
Processor Flags (Single Bits in the COSMAC 1802 Register Layout)
There are two min status flags that we might concern ourselves with. One of them is the Data Flag (DF). We can think of this as a “Carry” flag. We can use this to expand a value across multiple bytes if we need to. For example, if the result of a math function is above 255 for a single byte, then we set the carry. At this point, we can add the carry when we do the math for a higher byte.
Lastly, we have the IE bit, which is “Interrupt Enable”. This allows the processor to be interrupted during certain I/O conditions. Once you gain more experience as a programmer, you can use the processor interrupt for efficient I/O handling.
Summary of COSMAC 1802 Register Layout
In Short, you have 16 Registers that P and X point to for the program counter, and for Indexing. The N register also points to a 16 bit register for certain operations that require a memory address. Sometimes, using this method, you need to think 2 or 3 levels deep in addressing while you are writing a program. However, in the long rung, it does make for more efficient usage of memory. Consult the COSMAC 1802 User manual for more programming information.
For more information, visit the Vintage Computers Category Page!
— Ricky Bryce