Instructions

The computer is controlled by a series of instructions held in memory (a computer program) that are loaded into the instruction register one at a time and executed. Each instruction is formed of an 8-bit ‘op-code’ and falls in to a class of related instructions (identifiable by the leading part of the op-code).

If you’d like to try out the instructions there’s a full simulation of my relay computer available here which also has additional documentation. If you’d like to know even more you can find source code in my GitHub repo as follows:

  • relay-computer-model - the core model which simulates my relay computer on a wire-by-wire basis (written in TypeScript).
  • relay-computer - the simulator UI which wraps the model above and provides additional documentation and functionality (written in Angular).

The list of available instructions is as follows:

ALU Operation

ALU 8
1 0 0 0 r f f f

Performs an arithmetic or logic operation on the B (and optionally C) register(s).

  r = destination register (0-A, 1-D)
fff = function code (000-NOP, 001-ADD, 010-INC, 011-AND, 100-OR, 101-XOR, 110-NOT, 111-SHL)

Branch/Call & 16-bit Load Immediate

GOTO 24
1 1 d s c z n x
h h h h h h h h
l l l l l l l l

Branches to a given address if stated condition register flag(s) is set. Address of next instruction can optionally be saved in XY register. M register can also be loaded with 16-bit value (without jump).

d = destination register (0-M, 1-J)
s = 1 = load PC if sign bit is set (if negative); 0 = ignore sign bit
c = 1 = load PC if carry bit is set (if carry); 0 = ignore carry bit
z = 1 = load PC if zero bit set (if result is zero); 0 = ignore if zero bit set
n = 1 = load PC if zero bit clear (if result is not zero); 0 = ignore if zero bit clear
x = 1 = copy PC to XY; 0 = no copy
hhhhhhhh = address high byte (to set in M2/J2)
llllllll = address low byte (to set in M1/J1)

8-Bit Move

MOV8 8
0 0 d d d s s s

Copies the content of one 8-bit register to another.

ddd = destination register (000-A, 001-B, 010-C, 011-D, 100-M1, 101-M2, 110-X, 111-Y)
sss = source register (000-A, 001-B, 010-C, 011-D, 100-M1, 101-M2, 110-X, 111-Y)

16-Bit Move

MOV16 10
1 0 1 0 0 d s s

Copies the content of one 16-bit register to another.

d = dest reg (0-XY or 1-PC)
ss = src reg (00-M, 01-XY, 10-J, 11-AS)

Load Immediate

SETAB 8
0 1 r d d d d d

Loads a value between -16 and +15 in register A or B.

    r = destination register (0-A, 1-B)
ddddd = value (-16..15)

Load Switches

LDSW 10
1 0 1 0 1 1 0 d

Loads the value set on the front panel switches into register A or D.

d = destination register (0-A, 1-D)

Halt

HALT 10
1 0 1 0 1 1 1 r

Halts execution of the program (optionally reseting the program counter from the front panel switches).

r = reload program counter (0-no reload, 1-reload from switches)

There’s also a video summary (as at Jan 2020) of the available instructions: