Super Simple CPU

Installation

Download and run Super Simple CPU.jar

It is an executable JAR file.

It should run when you double click it.

If it doesn't...

  • on Windows, you may need to change the default program that is set to open jar files to Java platform binary (using Open with on Windows).

    • If you don't see that, you may need to install the Java Runtime. Check by typing "java –version" in a command prompt window.

    • If you get the message "'java' is not recognized as an internal or external command, operable program or batch file." you either don't have Java installed or there is a problem with the path, in either case...

    • If it still doesn't work, try saving this file to the same folder that the .jar file is in and double click it. SSCPU.bat

  • on MacOS, go to System Preferences > Security and Privacy > General and from there you should be able to open the jar file or modify your settings to allow it to run

For more information read the following:

OPCODES

Binary Mnemonic Short Explanation

--------------------------------------------

1111 STP Stop the computer

0001 ADD Add accum. to operand

0010 SUB Subtract operand from accum.

0011 LOD Load memory cell into accum.

0100 LDI Load immediate into accum.

0101 STO Store accum. into memory cell

0110 INP Input value and store into accum.

0111 OUT Output the value from accum.

1000 JMP Jump to instruction

1001 JNG Jump to instruction if accum<0

1010 JZR Jump to instruction if accum=0

More Info

MORE ABOUT THE INSTRUCTIONS

==================================================================

1111 STP -- this stops the computer, no more fetch/decode/execute

cycles until you reset.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0001 ADD -- fetch a number from memory and add it to the

contents of the accumulator, replacing the value

value in the accumulator.


E.g. 0001 000000001111 -- get the value at memory location 15

and add that to accumulator.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0010 SUB -- just like ADD, only subtract.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0011 LOD -- fetch a number from memory and store it into

the accumulator, replacing its old value.


E.g. 0011 000000001111 -- get the value at memory location 15

and store that value into the accumulator.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0100 LDI -- load immediate; the value to be put into the

accumulator is the rightmost 12 bits of the

instruction; do not go to memory like LOD


E.g. 0100 000000001111 -- store the value 15 into the

accumulator.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0101 STO -- store the accumulator's value into memory at the

indicated location.


E.g. 0101 000000001111 -- store the accumulator's value

into memory location 15.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0110 INP -- ask the user for one number and store that into

the accumulator.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0111 OUT -- copy the value in the accumulator to the output

area.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1000 JMP -- jump to the instruction at the indicated memory

address.


E.g. 1000 000000001111 -- put the value 15 into the PC

which will cause the next instruction to

be taken from location 15 of memory.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1001 JNG -- jump to the instruction at the indicated memory

location if the accumulator's value is negative;

otherwise just add 1 to the PC.


E.g. 1001 000000001111 -- put the value 15 into the PC

if accumulator < 0, otherwise go to the

next instruction.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1010 JZR -- jump to the instruction at the indicated memory

location if the accumulator's value is zero;

otherwise just add 1 to the PC.


E.g. 1010 000000001111 -- put the value 15 into the PC

if accumulator = 0, otherwise go to the

next instruction.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HELP

This applet demonstrates the fetch/decode/execute cycle of a very simple von-Neumann computer.

Put your program in the 16 memory cells and click run.

Or select one of the examples. Then press load example and run.


Numbers are stored as 16-bit binary values, using 2's complement for negative numbers.

You can view the values in binary or decimal by checking or unchecking the appropriate box.

The CPU and memory are viewed separately.


When responding to the INP (input) instruction, type your value in the INPUT text area and press RETURN.

If you are viewing numbers in binary, you must enter the value in binary. Otherwise type a decimal number.


You can stop a program with an infinite loop by pressing the STOP button.


To restart an example program, click Load example again.

If you typed in your own program, click on RESET.


To view the program's actions slowly, click on the 1 step button to watch it advance just 1 instruction.