Whiteboardiac

Whiteboardiac is a silly little emulator for a very simple computer.  It has 100 decibytes of memory, where a decibyte is a decimal byte, two decimal digits from 0 to 99.  It also has 100 lines of program memory, each one from one to three decibytes.  Its output is a single seven-segment LCD display, and it has no input, though you can edit the memory.

You write programs in machine code.  For example:

37
62 5
0

… is a program to display the number “9” on the LCD.  Opcode 37 is “switch on all segments”.  Opcode 62 is “switch off segment X”, where X is the number following on the line.  Opcode 0 is “stop”.  The above was the first program I wrote with my son, the Boy Wonder, who is nine.

Here’s a longer example, which the Boy and I wrote during his second lesson. It creates a cycling display of LCD segments, reading its input from memory:

I’ve written the emulator in Delphi. It’s rather primitive. The current opcodes are as follows:

Opcode Arg #1 Arg #2 Effect
0 End program; reset program counter to 0
14 M Put a zero at memory cell M
15 M Add one to memory cell M
16 M Subtract one from memory cell M
17 X M Add X to memory cell M
18 X M Subtract X from memory cell M
19 M N Copy memory cell M to memory cell N
20 M A If memory cell M is zero, set program counter to A
21 M A If memory cell M is not zero, set program counter to A
22 A Set program counter to A
23 M Jump to memory cell M
25 A Save the program counter then set it to A
26 M Save the program counter then set it to memory cell M
27 Set the program counter back to the last saved value
37 Switch on all LCD segments
38 Switch off all LCD segments
61 S Switch on segment S (from 1 to 7)
62 S Switch off segment S
63 Toggle segment S
71 M Switch on segment at memory cell M
72 M Switch off segment at memory cell M
73 M Toggle segment at memory cell M