Test Programs for my 8-bit computer

In 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:

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!