TOUR

A quick tour of CARDIAC

CARDIAC ยท the debugger

The machine

Memory is 100 cells, 00 to 99, each holding a signed three-digit number. Instructions and data share the cells. The accumulator holds a sign and four digits. The program counter says which cell the next instruction comes from. Input is a deck of cards, one number to a card, and output is cards punched with numbers.

Cell 00 always holds 001, the start of the bootstrap that loads programs from cards. A jump leaves its return address in cell 99.

Instructions

The first digit of an instruction is the operation, the other two an address: 152 is CLA 52.

OpNameDoes
0INPread a card into the cell
1CLAclear the accumulator and add the cell
2ADDadd the cell to the accumulator
3TACif the accumulator is negative, jump to the address
4SFTshift the accumulator: left by the second digit, then right by the third
5OUTpunch the cell onto a card
6STOstore the accumulator in the cell
7SUBsubtract the cell from the accumulator
8JMPjump to the address; cell 99 gets 8 and the return address
9HRShalt and reset the program counter to the address

An example

Countdown prints 5, 4, 3, 2, 1, 0. Each line is a cell: address, contents, label, instruction, comment.

10  530  loop  OUT  n      print n
11  130        CLA  n
12  731        SUB  one    n - 1
13  316        TAC  done   below zero: stop
14  630        STO  n
15  810        JMP  loop
16  900  done  HRS  00
30  005  n     DATA 5
31  001  one   DATA 1

It's one of the examples in the debugger. Press Step (F11) to go one instruction at a time.

Strange Query Lab