HOME ] UP ] TM ] [ RAM ] Sequence ] Skip List ] Search ] Josephus ] SOE ] PCP ] Hanoi ] Queens ] Maze ] RPN ] Pattern ] Huffman ] BST ] AVL ] Splay ] Red-Black ] B-Tree ] Trie ] Quadtree ] Heap ] PQ ] Hashing ] Sorting ] Insertionsort ] Mergesort ] Shellsort ] Heapsort ] Tournamentsort ] Quicksort ] Binsort ] Radixsort ] Graph Traversal ] Critical Path ] Shortest Path ] MST ] Maxflow ] DynaProg ] DSN ] TSP ]


RAM Interpreter@wareseeker.com

What's RAM?

The programming language of RAMs has a very limited instruction set. Every (non-empty and non-comment-) line of the source code must start with the instruction number ("program line number") and then, one of the following instructions must follow:

Ri <- c
Ri <- Rj
Ri <- RRj
Ri <- Rj + Rk
Ri <- Rj - Rk
RRi <- Rj
IF Ri = 0 GOTO l
IF Ri > 0 GOTO l
GOTO l
STOP

where i, j and k are integers and represent the number of a register, l is an integer and represents an instruction number, and c is an integer constant. RRi is the indirect mode of addressing a register, that means not register i is used but the register with the number that is contained in register i.
When the program starts, the arguments are filled into the registers starting from register 0, all other registers are set to 0. The return value of the RAM is the value that is in register 0 after the RAM terminates.
For a detailed (and correct) explanation, please consult the book "Theoretische Informatik" by Klaus W. Wagner.

Example A (sum)

0 R0 <- R0 + R1

Example B (multiplication)

0 R3 <- 1
1 IF R1 = 0 GOTO 5
2 R2 <- R2 + R0
3 R1 <- R1 - R3
4 GOTO 1
5 R0 <- R2
6 STOP

Example C (ceiling division)

0 R3 <- 1
1 R0 <- R0 - R1
2 R2 <- R2 + R3
3 IF R0 > 0 GOTO 1
4 R0 <- R2
5 STOP

Example D (floor division)

0 R3 <- 1
1 R0 <- R0 + R3
2 R0 <- R0 - R1
3 R2 <- R2 + R3
4 IF R0 > 0 GOTO 2
5 R0 <- R2 - R3
6 STOP

(Courtesy of http://linux.wareseeker.com/download/java-ram-interpreter-1.0.rar/325066)


TOP

HOME ] UP ] TM ] [ RAM ] Sequence ] Skip List ] Search ] Josephus ] SOE ] PCP ] Hanoi ] Queens ] Maze ] RPN ] Pattern ] Huffman ] BST ] AVL ] Splay ] Red-Black ] B-Tree ] Trie ] Quadtree ] Heap ] PQ ] Hashing ] Sorting ] Insertionsort ] Mergesort ] Shellsort ] Heapsort ] Tournamentsort ] Quicksort ] Binsort ] Radixsort ] Graph Traversal ] Critical Path ] Shortest Path ] MST ] Maxflow ] DynaProg ] DSN ] TSP ]

Copyleft (c) 2003-3002, Junhui Deng
Last updated on 05.30.2012