The Random Acess Machine Emulator
The Random Access Machine (RAM; German: Registermaschine) is a mathematical model to help to evaluated algorithm by runtime and memory consumptions. The RAM runs on a low set of instructions. This set of instruction is turing complete. For more details about the set of instruction see the tab "Commands".
With this Emulator we want to give the possibility to run a RAM program. Details on how to use our RAM Emulator can be found on the tab "Functionality of Emulator". We also provide some examples program on the tab "Examples".
The RAM Emulator was created for the lecture "Höhere Algorithmik" at Freie Universität Berlin thought by Helmut Alt.
Run (Mode)
The "play" can be run in three modes:
- Run:
This mode will not take care of any breaking points or anything else expect the given code.
- Animated:
The code will be run by highlighting the current line and a specific amount of time will pass between each command. The register will also be colored: red -> writing, yellow ->reading as an indirect address, green -> reading as a direct address.
- Debug:
The debug mode will run until a break point is set, then the RAM hold and the "Next" or "Play" buttons can be pressed.
All modes will set the editor to read-only. After execution the editor will get the writing permission back.
Pause
The pause button can be pressed when the RAM is running in the "run" and "animated" modes. After pressing the pause button the processing of program code will end in the debug mode. Now you can continue with "Next" or a differed run mode.
Next
When the program is paused the "Next" button is enabled. After pressing the "Next" Button one line of code will be execute. Therefore, you can iterate step by step through the code. Please Note, all register can be manipulated between executes.
If the program stops at a break point or the pause button is pressed then "Next" button will be disabled. The code can run with this button step by step.
Reset
The reset button will always reset the RAM to not running and will restore the default value of the registers.
Link
The "Link" button should help you to share your code with your friends or teaching assistants.
Register add / remove
The + and - buttons on the right side will add and remove a register.
The RAM runs on a low set of commands.
Assignment
The signs for assignment are := / =. This command can change the state of a register.
Addressing
There are different ways of addressing registers. Directly, like R1 or indirectly (R1). For example, RAM runs with the registers R0=1, R1=2 and R3=3 with following program:
(R0)=22
R3 = 0
HALT
The RAM will end with the following values in the register: R0=1, R1=22 and R3=0.
Operations
The valid operations for this emulator are +,-,* and /. All operations are based on integers.
Label
Every line can be marked with a label simply by adding an alphanumerical word ending with ":" at the beginning of a line. Now the label can be used in GOTO statements.
GOTO Statements
There is a limited set of GOTO statements with and without conditions:
GOTO «Label»
Go to a label without any validation of a condition.
GGZ «Expression: Value or Register», «Label»
Go to the label if the expression is greater than zero.
GLZ «Expression: Value or Register», «Label»
Go to the label if the expression is less than zero.
GZ «Expression: Value or Register», «Label»
Go to the label if the expression is equal to zero.
Comments
Comments help to improve the readability of code. RAM code in particular needs to be commented because you need a lot of lines to realize simple things. The command are ";" or "/".
HALT
To complete the RAM successfully it needs to end with a HALT command.
Copyright (c) 2013 Simon Gene Gottlieb, Simon Koennecke
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please notice, the used Frameworks have following licenses:
- Bootstrap (CSS Framework): Copyright 2013 Twitter, Inc under the Apache 2.0 license.
- jQuery (JavaScript Framework): MIT license.
- ACE (JavaScript Editor): BSD license.