Testing the 6502

Now that I have connected the pins that I will be using, the input pins that I will not be using and the power supply pins, I would like to test if the 6502 is working. There are a number of ways that I could do this, the way that I will do it, is to place LEDs (with protection resistors) on the 16 address lines, see Figure 1. With power applied. the 6502 should run and LEDs should light up, showing that the 6502 is accessing different address lines.

testing the 6502
Figure 1. Testing the 6502

The test was successful and demonstrates that the 6502 is working. However, it doesn’t demonstrate anything further. The addresses that are being displayed are meaningless. What would be good would be to place to the 6502 into a known state and to run a program.

NOP

What I will do is create a hard-wired program! I will achieve this by using an OpCode named NOP. OpCode is short for Operation Code. An OpCode is an instruction that specifies an operation to be performed. NOP stands for No OPeration. NOP is an OpCode that does nothing, except for incrementing the program counter. If you look at table 1, you will see a section of the 6502 datasheet named OpCode matrix. This contains all of the different OpCodes that the 6502 perform. If you go to the row with E in it and across to the column with A in it, you will see NOP. This means that if EA is presented to the data bus, the 6502 will run the NOP. Also, if you look under NOP, you will see an i. The i denotes that a NOP takes two clock cycles to complete.

OpCode matrix
Table 1 OpCode matrix

EA is a hexadecimal number, we need its binary equivalent to know which values to place onto the data bus. EA is equal to 11101010 in binary. I will place 11101010 onto the data bus by connecting pins that need to see a 0 to ground and those that need to see a 1 to 5v, see image 1. I can then monitor the 16 address lines by watching the LEDs. The 6502 running the NOP should cause the program counter to increment each time and the address to increase. What should be seen is the address on the address bus being incremented in binary.

6502 NOP generator
Figure 2. NOP generator

Tip

When I am building a circuit that uses a large number of resistors and/or LEDs, I use an array. The advantages of these are that they contain one common pin, reducing wiring and they come in many different numbers., see Image 3.

Summary

I have tested the 6502 and proved that it is working, by watching LEDs connected to the address change on the address bus. I have created a hard-wired program using resistors that corresponds to the OpCode NOP. I was able to see the address bus increment, by watching the LEDs connected to the address bus.