Test Programs for my 8-bit computer
06 Jan 2026In my previous post, I announced that build of Ben Eater’s 8-bit Computer is done. That means it is now time to put it through its paces!
My goal is to develop a sequence of programs that will test every opcode that is available to us in the basic instruction set.
The total instruction set includes:
-
LDI x: Load the valuexdirectly into the A-register -
LDA x: Load the value specified at addressxinto the A-Register -
STA x: Store the value in the A-register into memory locationx -
HLT: Stops program execution -
OUT: Prints the value in the A-register to the display -
ADD x: Adds the value stored in memory locationxto the value in the A-Register and store the result in the A-register. -
SUB x: Subtracts the value tored in memory locationxfrom the value in the A-Register and store the result in the A-register. -
JMP x: Continue program execution at addressx. -
JZ x: Continue program execution at addressxif the Zero-bit is set in the flags. -
JC x: Continue program execution at addressxif the Carry-bit is set in the flags.
Program 1
0: LDA [14]
1: ADD [15]
2: OUT
3: HLT
14: #28
15: #14
This program test: LDA, ADD, OUT, and HLT. If you enter the program and get
the value 42 printed on the display when you run it, those instructions work.
This is the program that Ben uses in his videos.
Program 2
0: LDI #1 ; 0101 0001
1: OUT ; 1110 0001
2: ADD [15] ; 0010 1111
3: JMP 1 ; 0110 0001
15: 0000 0001
Start counting at 1 and increment the counter each time the program loops.
This program adds tests for LDI and JMP. If your program starts counting at 1, shows the
value on the display, and then continues to the next number, the instructions
work.
Program 3
0: LDI #15 ; 0101 1111
1: OUT ; 1110 0001
2: SUB [15] ; 0011 1111
3: JZ 0 ; 1000 0000
4: JMP 1 ; 0110 0001
15: 0000 0001
Start counting at 15 and count down to 0. When the counter reaches 0, start back at 15. After each counter update, show the result on the display.
This program adds tests for SUB and JZ. The expected behavior is that
you’ll see the counter count down from 15 to 0 (inclusive) and then restart at
Program 4
0: LDI #10 ; 0101 1010
1: STA #15 ; 0100 1111
2: LDI #5 ; 0101 0101
3: LDA #15 ; 0001 1111
4: OUT ; 1110 1111
5: HLT ; 1111 1111
I couldn’t really come up with a fancy one, so I kept it simple. This programs loads the value 10 into the A-register, and the stores it at memory address 15. It then changes the A-register to 5, followed by retrieving address 15 and storing it into the A-register. Lastly, the program ends.
This program adds tests for STA. If the display shows the number 5, there is
a problem. If it shows the number 10, we’re all good to go.
UPDATE: I forgot to check for JC. To be continued!