CARDIAC

Code
Published

March 1, 2022

Modified

March 1, 2022

CARDboard Illustrative Aid to Computation…

Print out (Johan Von Konow, CC-BY-NC-SA)…

CARDIAC, left-hand CPU section, right-hand memory section

Components…

Architecture

Control unit …three part cycle

  • …fetch instruction to the instruction register (IR)
  • …increment program counter (PC)
  • …execute instruction register

Accumulator…

  • …4-digit number (overflow for numbers > 999)
  • ALU (arithmetic logic unit) supports…
    • …addition
    • …subtraction
    • …decimal shifting (left/right)
  • …test for sign-negative or -positive

Memory…

  • …location stores a signed three-digit decimal number
  • …locations identified by numbers 00 through 99
    • 00 always contains the value 001
    • 99 always contains a value between 800 and 899

I/0…

  • …card reader (input) and a card writer (output)
  • …hold exactly one signed three-digit number
  • …read by way of the INP instruction

CARDIAC Control Unit and Accumulator

Instructions

Identified by an opcode (operation code)

Opcode Mnemonic Description
0 INP read input …store to memory location
1 CLA load content from memory location to accumulator
2 ADD add accumulator to memory location …store to accumulator
3 TAC acc. negative …operand address to PC …otherwise next instruction
4 SFT shift accumulator
5 OUT write content of memory location to output
6 STO copy accumulator content to memory location
7 SUB subtract content of memory location from accumulator
8 JMP copy PC to address 99 …copy operand address to PC
9 HRS halt (stop machine) …reset PC
  • …mnemonic abbreviations
  • Oxx …three-digit decimal numerals (non-negative)
    • …opcode O left most digit
    • xx ..lower order digits …address/memory location

Anatomy of opcode decoding…

  ┌──── opcode (here for instruction INP)

  034   ➡  read from input and store content to memory location 34
   ││
   └┴── address (here memory location 34)
  ┌──── opcode (here for instruction ADD)

  235   ➡  add content from memory location 35 to accumulator
   ││
   └┴── address (here memory location 35)

Program

Simple addition of two numbers…

Line   Opcode    Description
──────────────────────────────
01     034       read input A
02     035       read input B
03     134       load input A to accumulator
04     235       add B to accumulator ...sum S in accumulator
05     636       store S
06     536       print S
07     900       halt