The PRIMA (Primitive Machine) Applet Manual

return to the applet
An applet byAndy Nahapetian

If you just want to know which opcodes are supported, look at the command list

To use this applet you need a Java-enabled Browser such as: Netscape 2.0, the Microsoft Explorer, Hotjava or the appletviewer from Sun. Point your browser to the address: http://tech-www.informatik.uni-hamburg.de/applets/prima/prima.html. After the applet starts, you will see the block diagram of the PRIMA machine. There are 7 UI elements at the bottom of the screeen: (from left to right):

The speed controller

You can control the speed of the animation with this scrollbar.

The "clock" button

This button simulates a clock signal to the PRIMA. While the animation is running , the applet will not react to user input.

The "start" button

This button runs the programm that is in the RAM. You first have to load a program into the RAM to use this function. (see "the edit button"). Unlike the clock button, this function has its own thread and user input will be processed while the program runs.

The "reset" button

Resets the PRIMA. The RAM will not be erased by this function, but the PRIMA returns to the state it was in before the program was started.

The "edit" button

You can invoke the "Edit RAM" window with this button. This window is used for loading program examples into the RAM and viewing the source code. You can also write your own programs in this window. See "edit RAM" for details on using the Edit window.

The "command" button

This button invokes the "Command" window. This window shows the current command that is being executed by the PRIMA and explains what it does. For details, see "The Command window".

The radix menue

You can switch between number representations with radix 10(decimal) or radix16(Hexadecimal) with this menue.

The PRIMA windows

The main window

In this window, you see the building blocks of the PRIMA and the control panel at the bottom of the window. You see an image of the PRIMA, explaining the different elements:

edit RAM

Here is a screenshot of the "edit RAM" window, with an open program example.


image 5: the "Edit RAM" window

The control panel

The "load" button

You can load a program into the RAM with this button. To do this you have to choose a programm from the choice or type in your own program.

The "open" button

You can view the program of your choice with this button. First you have to choose a program from the menue. This function does not load the program into the RAM. You still have to use the load button to do this.

The "new" button

If you want to write your own program, use this button. The text editor will be cleared and you can type in your program. The commands are given in decimal numbers, followed by the address on which they should act. See the command list for the available commands. The commands and addresses have to be separated by at least one space. After typing in the program, you can load it into the RAM with the load button. To verify your code,you can use the show button. This button will show the code in the RAM and comment it.

The "show" button

This button shows the current programm in the RAM. If the programs save their results in variables, you can use this function to see the values of the variables after program execution.

The program examples menue

You can choose on of the program examples here. To view or load the programm, you have to use the open or the load button.

The "Command" window

This window shows the current comman that is being executed by the PRIMA, and explains what it does.


image 6: the "Command" window

Example for using the PRIMA applet

To use this applet you need a Java-enabled Browser such as: Netscape 2.0, the Microsoft Explorer, Hotjava or the appletviewer from Sun. Point your browser to the address: http://tech-www.informatik.uni-hamburg.de/applets/prima/prima.html. After the applet starts, you will see the block diagram of the PRIMA machine. There are 7 UI elements at the bottom of the screeen: Press the edit button. A window will pop up called "Edit RAM" (see image 5).

Now you can choose a program example from the menu. We will take a look at the example program "addition". Since this is the default choice, we just have to press the open button to look at the program. After a short delay, we will see the program code and its explanation in the window.

Now we want to load the program into the RAM by pressing the load button.Press the start button in the main window. The program will start and you will see an animation of the data flow. You can control the speed of the animation with the speed control. Pressing the command button will pop up a window that shows the current executing command (see image 6).

The program end in an infinite loop. You can recognize this by the repeating values and addresses in the RAM. Now we can stop the program and view the results in the "Edit RAM" window. We expect to see the result of the addition 12 + 7 at the RAM address 8.

To show the contents of the RAM, press the show button. Check the value at address 8. As expected, the value is 19.

To write your own program press the "new" button. You can type in your program now. The commands must be decimal numbers with a valid opcode. The addresses must be smaller than 256.

Let us write our own programm to add two numbers. Please type in the following program:
9 8 0 9 72 10 128 6 14 2
The program loads(9) the number 14 ($8=14) in the accumulator. Then it adds(0) a 2 ($9=2) to the accumulator. It then saves (72) the value of the accumulator at the address 10. Then it goes into an infinite loop (128 6).

Now we can load the program into the RAM by pressing the load button. To verify the program we look at the contents of the RAM by pressing the show button. Now we can see the commented version of the program and it is easier to read. We execute the program by pressing the start button. Once the programm goes into an infinite loop(address 6,7), we can stop the program and view the contents of the RAM. As expected, the address 10 contains the value 16.
return to the applet