CPU Simulator

This Java applet simulates a simple microprocessor, based loosely upon the 6502 (the processor inside the BBC Micro). It can only handle a few of the 6502 instructions.

I have also written a series of lessons to go with this program designed to introduce students to the idea of computer architecture and the 6502 processor in particular.

Online tests on Computer Architecture

CPU Simulator - How to use the program

To write a program, type the instructions in the text area near the top of the screen. Then click on to convert that program into machine code instructions. By default the program is assembled to addresses starting at 500 (decimal), but this can be altered by the PC program directive. You can then click on to run the program through straight away, or on to run the program one instruction at a time.

Below the program window is a series of rectangles representing the memory. The memory contents is always displayed in black, apart from the one memory location which indicates the current position of the program counter register, which is represented in red.

As well as showing the memory where the program is located, the first 10 locations of zero page memory are displayed on the right. Zero-page memory is generally used for working out, so this will let the viewer track calculations as they take place. There are two arrows just to the right of this zero page window - these move this window onto the zero page forward and backwards along the zero page.
The fourth icon at the top of the applet is the icon. By default, the values in the registers and the contents of the memory addresses are shown in decimal format. However, clicking on this icon causes these values to be displayed in hexadecimal (as shown by the & symbol in front of them). The caption on the icon changes to , indicating that clicking on the icon again will return the numbers to decimal format.

Saving and Loading Assembler Programs

One thing you will notice after a cursory glance at the screen is that there is no save or load (open) facility. This is because saving and loading are notoriously difficult things to do using Java.

Instead I have ducked the problem. The way to save programs that you have written/altered in Assembly language using this program is to highlight the code in the text window which forms part of the program, and then use <Ctrl> + <C> to copy the text into the clipboard. This is the keyboard equivalent of selecting the text and pressing the Copy key in Microsoft Word.

Then move into a program that is capable of dealing with plain text, such as Notepad, and click onto the text area of that program. Finally, press <Shift> + <Insert> to paste the text in from the keyboard into the text editor. Now you can use the perfectly adequate Save facilities on that program. Opening programs involves the movement of information the other way - open the file inside Notepad, highlight the text, then click on <Cut> or <Copy>. Then you can paste it back into the text area that you see present on the screen, using <Shift> + <Insert>.

To summarise, remember ...

<Ctrl> + <X> = 'Cut'

<Ctrl> + <C> = 'Copy'

<Shift> + <Insert> = 'Paste'


Home page