Pages

Thursday, 22 January 2015

Unlimited Register Machine (URM) Example

The goal of this URM is to calculate the function: i + (2*j) + k and place the result in R4, where for example i = 2, j = 3 and k = 7. So the function is now 2 + (2*3) + 7

URM Program:

Z (4)
  1. J (3, 4, 6)
  2. S (1)
  3. S (2)
  4. S (4)
  5. J (1, 1, 1)
  6. J (2, 4, 10)
  7. S (1)
  8. S (4)
  9. J (1, 1, 6) 
  10. J (1, 3, 14)
  11. S (3)
  12. S (4)
  13. J (1, 1, 10)


The following points are observation about the above program.
  • The program uses registers R1, R2, R3 and R4
  • If r3 = r4, the first instruction involves a jump to instruction 6
  • If r2 = r4, the third instruction involves a jump to instruction 10
  • If r1 = r3, the fifth instruction involves a jump to instruction 14
  • The instructions 5 involves jumping back to the first instruction if r1 = r1 and so, as this is always true, the effect of this instruction is the unconditional jump “go to instruction number 1”. This also applies for instructions 9 and 13.
  • The overall effect of the first and third, the fourth and sixth and the seventh and tenth instructions is that the program includes 3 ‘do while r3 ≠ r4, r2 ≠ r4 and r1 ≠ r3’ loops.

Illustration of URM transaction:



Instructions
R1
R2
R3
R4

2
3
7
0
1
2
3
7
0
2
3
3
7
0
3
3
4
7
0
4
3
4
7
1
5
3
4
7
1
1
3
4
7
1
2
4
4
7
1
3
4
5
7
1
4
4
5
7
2
5
4
5
7
2
1
4
5
7
2
2
5
5
7
2
3
5
6
7
2
4
5
6
7
3
5
5
6
7
3
1
5
6
7
3
2
6
6
7
3
3
6
7
7
3
4
6
7
7
4
5
6
7
7
4
1
6
7
7
4
2
7
7
7
4
3
7
8
7
4
4
7
8
7
5
5
7
8
7
5
1
7
8
7
5
2
8
8
7
5
3
8
9
7
5
4
8
9
7
6
5
8
9
7
6
1
8
9
7
6
2
9
9
7
6
3
9
10
7
6
4
9
10
7
7
5
9
10
7
7
6
9
10
7
7
7
10
10
7
7
8
10
10
7
8
9
10
10
7
8
6
10
10
7
8
7
11
10
7
8
8
11
10
7
9
9
11
10
7
9
6
11
10
7
9
7
12
10
7
9
8
12
10
7
10
9
12
10
7
10
10
12
10
7
10
11
12
10
8
10
12
12
10
8
11
13
12
10
8
11
10
12
10
8
11
11
12
10
9
11
12
12
10
9
12
13
12
10
9
12
10
12
10
9
12
11
12
10
10
12
12
12
10
10
13
13
12
10
10
13
10
12
10
10
13
11
12
10
11
14
12
12
10
11
14
13
12
10
11
14
10
12
10
11
14
11
12
10
12
14
12
12
10
12
15
13
12
10
12
15
STOP
12
10
12
15

No comments:

Post a comment