Answered You can hire a professional tutor to get the answer.

QUESTION

MARIE Lists (35 marks) This section will ask you to prepare a MARIE program which is capable of computing the range (difference between the minimum...

2.MARIE Lists ​(35 marks)

This section will ask you to prepare a MARIE program which is capable of computing the range (difference between the minimum and maximum element) of a list of items. It is broke up into smaller steps for you below.

Most of the tasks require you to write code and test cases. The code must contain               comments and should be submitted as. mas files together with the rest of your assignment. The test cases should also be working, self-contained MARIE assembly files.

 In-Class interviews: ​​You will be required to demonstrate your code to your tutor after the              submission deadline. Failure to demonstrate will lead to ​zero marks ​​being awarded for the             part 2 and 3 of this assignment.

Background - Lists of data in computer programming, quite often we have to deal with lists of numbers (or other types of data). There are different approaches to store lists in computer memory. The approach we will study here works like this: All data in the list is stored sequentially in memory, i.e. the list will occupy a contiguous block of memory. Other than list data, we also need to keep a record of list size. It will be useful whenever we have to process all the items in a list.

In a MARIE program, a list of four numbers can be defined as below. Note how we have to store size in a separate variable.

ListAddr, ADR List

Size, Dec 4

List, Dec 2

     Dec -4

    Dec -1

   Dec 7

Note that ADR is used to load the address of a label into another label. For example,

assuming label List ends up in memory at address 2A. Now if we want to use indirect

addressing instructions (e.g. LoadI), we need to get the address of List (i.e., 2A). The ADR

keyword will be helpful here, So the line ListAddr, ADR List will result in the value 2A

being placed at the label ListAddr. So now we can use an instruction like

LoadI ListAddr in order to indirectly load from the list. Try this out in the simulator to get

an idea how it works.

2.1.1 Reading in a list of integers (7 marks)

Prepare a MARIE program which first reads in a positive integer, Size (representing the

number of items which will be received) and then reads in a group of integers one item at a time until there are Size of them and stores these into memory sequentially, starting from

an address which is referenced by ListAddr (add described in the background section).

After entering all the value, display the list (use output).

2.1.2 ListInput Subroutine (4 marks)

Convert the above program into a subroutine called ListInput. When the main program

runs, it should call the subroutine to get size and list numbers as input from user. After

entering all the values, display the list (use output).

2.2 Finding the minimum and maximum (14 marks)

Prepare a MARIE subroutine FindMinMax which takes the size and address of a list

(ListAddr), and iterates over the list items to find (display) the minimum and maximum

value.

As a hint, you may assume the first read item is the maximum (and minimum) and then

update the maximum (or minimum) if you find any later elements exceed it (or smaller). A

pseudo code of this method is given below

let min = first_item, max = first_item, count = size

while count > 0

item = get_next_item_from_list

if (item > max)

max = item

if (item < min)

min = item

count = count - 1

end_while

In the main program, call the FindMinMax subroutine and output the minimum and

maximum values obtained respectively. For this task, hard code the list and the size of the

list, the size should be greater than 3.

2.3 Finding the range (3 marks)

Prepare a MARIE program which takes the maximum and minimum of the list of items (as

determined by your code in parts 2.2) and computes the difference between them (maximum

- minimum) and outputs them (minimum, maximum and range respectively). This is called

range in statistics.

A pseudo code of this method is given below

2.4 Bringing it all together (7 marks)

Prepare a MARIE program that gives user a choice of reading in a list or compute the range

of list. If user inputs '1', you should call ListInput subroutine. When user inputs '2' you

should use the FindMinMax subroutine to find the minimum and maximum, and to calculate

the range of the numbers. Display these 3 values on the output (minimum, maximum and

range respectively). The program will continue in an infinite loop always asking user to enter

a choice (1 or 2). If the user input '2' before '1', your program should include hard code list

with minuman of 4 items to work with.

3. ROT-10 Cipher in MARIE (10 Marks)

In this task, you will implement a variation of classical Caesar Cipher in MARIE. In this

method, a given piece of text in encrypted such that each letter is replaced by another letter

some fixed number of positions down the alphabet. We will specifically work with ROT-10,

i.e. letter 'a' is replaced by 'k' (which occurs 10 positions later) and so on, as shown below

Your program should proceed as below

- Receive the original text as input from the user letter by letter. You may wish to keep

track of size of list (as done in 2.1)

- User will indicate end of string by entering a '0' character (as Unicode input)

- Once all the input is complete, display the input data in the output (as Unicode)

- Calculate ROT-10 encryption on the data

- Only lower-case letters should be encrypted. All other characters should be left as-is.

- Display encrypted text in output in a new line

- The '0' character should not be displayed.

Note that you can switch the input box in the MARIE simulator into different modes: use the Unicode mode to enter and display the characters.

Below is an example of input text and encryption result. Note how capital letters and

numbers remain unencrypted.

Hint: All lower-case letters appear in a sequence in the Unicode/ASCII table from hex 61 to

hex 7A.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question