Modelling unlimited register machines

Assignment Help Programming Languages
Reference no: EM132993058

ITECH 5403 Comparative Programming Languages

Modelling Unlimited Register Machines.

Introduction.
Unlimited Register Machines (or URMs) are mathematical abstractions of real-life computers. They are more user-friendly than Turing Machines and make an ideal introduction to machine models of computability. Any effectively computable function can be computed on a URM.
URMs were invented by J. C. Shepherdson and H.
E. Sturgis.
In this assignment you are required to implement Unlimited Register Machines (URMs) using three different languages - Java, C and Python. i.e., you are required to write programs in these languages that imitate the functionality of URMs (to develop Virtual URMs).

1. Description of the Unlimited Register Machines,

A URM has registers R0,R1,R2,..., which store natural numbers r0,r1,r2,...:

R0

R1

R2

R3

R4

R5

...

r0

r1

r2

r3

r4

r5

...

A URM program is a finite list of instructions, each having one of the four following basic types:

Instruction Type

Notation

Effect

Zero

Z(n)

rn = 0

Successor

S(n)

rn = rn+1

Transfer

T(m,n)

rn = rm

Jump

J(m,n,q)

If rn = rm go to instruction q, else go to the next instruction.

• Z(n) - sets value of register Rn to zero and moves to the next instruction in the program list.
• S(n) - increases the value of register Rn by one and moves to the next instruction in the program list.
• T(m,n) - copies the value of Rm to Rn and moves to the next instruction in the program list.
• J(m,n,q) - if rm = rn, the instruction at index q in the program list is executed. Else the next instruction in the program list is executed.

URM programs are zero-based indexed lists of instructions, i.e., instructions in a program can be accessed via indexes and the index of the first instruction is 0.

A URM program starts with the first instruction (at index 0) and executes instructions consecutively, one by one, unless it encounters the Jump instruction. The program halts after execution reaches the end of the program list or a Jump instruction J(m,n,q) is executed, where q is not a valid index in the program list.

URM is used to compute functions that take integer parameters and return an integer value.
Input and Output conventions: To compute a function
ff(nn11, ... , nnkk), we start with nn11, ... , nnkk in registers RR00, ... , RRkk-11, respectively, and with 0 in all the other registers. If computation halts, the output is the number in register R0.

2. Programming tasks.

You are required to implement Unlimited Register Machines (URMs) in three different languages - Java, C and Python.

Implementation Requirements:
- Set of URM's registers should be implemented as an array or list of integers.
- Instruction types should be coded by the integers
{0,1,2,3}: use 0 for Z, 1 for S, 2 for T and 3 for J.
- Instructions should be represented by arrays or lists of integers, for example, instruction J(1,2,4) in your Python program should be represented by the list [3,1,2,4].
- Programs should be implemented as arrays or lists of instructions. For example, the program from Example 1 should be represented by the following list of lists in your Python implementation:
program = [[3,1,2,4],[1,0],[1,2],[3,0,0,0]]

Also, you are required to write the following three

functions/methods in each of the implementations:
(1) isValidCommand(command) - takes a list/array of integers and returns true if it is a valid URM command, otherwise returns false.
(2) isValidProgram(program) - takes a list of instructions and returns true if it is a valid URM program, otherwise returns false.
(3) run(program, registers) - runs the URM program on the list/array of registers.
(4) main() - this is a testing method/function where you test your implementation of URM by running the program from Example 1.

3. Write a URM program.
In this task you are required to write and test a URM program that computes the product of two numbers.

Attachment:- Comparative Programming Languages.rar

Reference no: EM132993058

Questions Cloud

What is the operating profit or loss : A clothing retailer buys winter coats from one of its suppliers for $67.50. What is the operating profit or loss on the coats sold during the promotional sale
What would be the yield to maturity : A bond is currently priced at $900 on a par value of $1,000. If you buy the bond, and hold it to maturity, what would be the yield to maturity
What would be the company cost of goods sold in dollars : What would be the company's cost of goods sold in dollars on December 31 if the company used perpetual, weighted average (WA) costing method
Prepare production cost report : Production: 10,750 units finished and transferred out; 3,600 units started that are 100% complete in terms of materials. Prepare production cost report
Modelling unlimited register machines : Modelling Unlimited Register Machines - implement Unlimited Register Machines (URMs) using three different languages
What account would we debit : On July 2, we had accrued taxes of $36,000. What account would we debit when we record the adjusting entry for accrued taxes on July 2
What is impairment loss compared to depreciation expense : On 1 July 2018, Herbal Ltd acquired an asset for $1,000,000, which it is depreciating using the straight-line method over 20 years. What is impairment loss
What would the selling price have to be : Assume that Riverbed Company sells the same number of units in 2017 as it did in 2016. What would the selling price have to be
Identify and explain the business risks : Each centre operates early morning fitness sessions for members that run from 07.00 to 08.00 on four days each week. Identify and explain the business risks

Reviews

Write a Review

Programming Languages Questions & Answers

  Probability line is executed in nth iteration of for loop

What is the probability that line is executed during the nth iteration of the for loop? What is the exact expected number of executions of line?

  Which code snipped correctly imports the java arraylist

Of the sorting algorithms we've learned election sort, insertion sort, and merge sort is merge sort the fastest in every case? Why?

  Write a program that will sort a basket of clothes

Write a program that will sort a basket of clothes into their proper drawers. If you were not aware you are sort clothes by their type in this order.

  Write a function that accepts an array and a value

Write a function that returns a string containing random characters where the length must be equal to the value of the parameter

  Write a program to output accumulated values for each month

Write a program to output accumulated values for each month, given a set amount saved each month, until the accumulated amount reaches a set goal amount.

  Show tic-tac-toe game scenario diagram

The assignment is not to implement this game in Ruby. Rather, the assignment is to use scenario diagrams to discover the objects, their responsibilities, and the messages they respond to

  WAP that takes as input an unordered list of integers

Write a program that takes as input an unordered list of integers, creates a Btree of minimum degree t=4 and then outputs the sorted list of integers.

  Create two storefront websites

CSE2ICX Internet Client Engineering - Server-Side Web Programming - Apply the principles of Web user interface design in analysing and building Web sites

  Create logic for program to count readers by genders

Create the logic for a program that would produce a count of readers by gender within age group - that is, under 20 females, under 20 males, etc.

  Program to print chains of numbers within a range

Write a program to print the chains for the numbers within a range that the user specifies.

  Create a class named account with data fields

Create a class named Account with data fields for an account number, payment amount and balance as well as the appropriate set and get methods. Include a constructor method that contains no arguments.

  Evaluate the use of an ide for development of applications

D/615/1618-Programming-Pearson BTEC Levels 4 and 5 Higher Nationals in Computing Specification- Define basic algorithms to carry out an operation.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd