CARDIAC Instruction Set
CARDIAC (CARDboard Illustrative Aid to Computation) is a learning aid developed for Bell Telephone Laboratories in 1968 to teach high school students how computers work. The computer operates in base 10 and has 100 memory cells which can hold signed numbers from 0 to 999. It has an instruction set of 10 instructions which allows CARDIAC to add, subtract, test, shift, input, output and jump.
| Opcode | Instruction | Description |
|---|---|---|
| HRS x | Halt and reset | Move bug to the specified cell, then stop program execution. |
| CLA x | Clear and add | Clear the accumulator and add the content of a memory cell to the accumulator. |
| STO x | Store | Store the content of the accumulator into a specified memory cell. |
| ADD x | Add | Add the content of a memory cell to the accumulator. |
| SUB x | Subtract | Subtract the contents of a specified memory cell from the accumulator. |
| SFT xy | Shift | Shifts the accumulator x places left, then y places right, where x is the upper address digit and y is the lower. |
| JMP x | Jump | Jump to a specified memory cell. The current cell number is written in cell 99. This allows for one level of subroutines by having the return be the instruction at cell 99 (which had '8' hardcoded as the first digit. |
| TAC x | Test accumulator content | If the content of the accumulator is less than 0, jump to a specified memory cell. |
| I/O | ||
| INP | Input | take a number from the input card and put it in a specified memory cell. |
| OUT | Output | take a number from the specified memory cell and write it on the output card. |
Devine's Gyo
The instruction set can be slightly improved by removing the need for the INP and OUT opcodes by mapping INP to the memory cell 98 and OUT to 100. Another valuable modification to the instruction is to add an addressing mode which adds the power of indirection to the CARDIAC:
- label, i is the value in the cell label[i].
Here is a little program that prints the characters in a string using the extra addressing mode:
CLA zero ; Load 0 in accumulator. STO i ; Set value of accumulator into i. loop CLA text, i ; Load text[i] in accumulator. TAC end ; Jump to end if -1. STO 100 ; Write to Output. CLA i ; Load i in accumulator. ADD one ; Add i+1 in accumulator. STO i ; Store i+1 in i. JMP loop ; Jump to loop. end HRS ; Stop. zero 0 one 1 i 0 text H e l l o -1
incoming: paper register wdr computer