Essay Help Services

MARIE and Instruction Set Architecture

Home Recent Questions MARIE and Instruction Set Architecture

Task
Question 1 – MARIE Assembly [5 + 5 marks]
In this task you will write a program in MARIE assembly language, to work out if a given year is leap year or not. Leap years are those that are divisible by 4, except the years that are divisible by 100. But the centurial years are leap years if they are divisible by 400. For example 1980 is a leap year because it is divisible by 4 only, 2100 is not a leap year because it is divisible by both 4 and 100, and 2000 is a leap year because it is divisible by 400.

You will do this task in two steps.

(a) Remainder
To work out if a number is exactly divisible by another number, the obvious method is to perform division and look at the remainder. A zero remainder means dividend is exactly divisible by divisor. In this part, you will write a MARIE code for calculating remainder of a division. The following pseudo code implements the algorithm for remainder.

get X
get Y
repeat until X < Y:
    X ← X – Y
display X

Your program should implement the above algorithm in MARIE. It will get X (dividend) and Y (divisor) as input from the user, and display the final X value which would be the remainder of division.

(b) Leap Year
In this task you will use the code written in part (a) to find out if a given year is leap year or not. The program will ask user for an input year (e.g. 1996) and work out and display a ‘1’ or ‘0’ in the output to indicate if given year is leap or not.

An algorithm to determine leap year is given below (with comments). Implement this algorithm in MARIE.

if (year modulo 4 ≠ 0)          / if year is not divisible by 4

then output 0 and exit          / then it is a common year

else if (year modulo 100 ≠ 0)   / if year is not divisible by 100

then output 1 and exit          / then it is a leap year

else if (year modulo 100 ≠ 0)   / if year is not divisible by 400

then output 0 and exit          / then it is a common year

else output 1 and exit          / otherwise it is a leap year

As you can see from the pseudo code, the modulo calculation is applied three times to get the final result. You will need to copy the modulo code from part (a) and paste it (and adapt it) 3 times in your program.
Assume that user will always provide valid numbers as input, that is, do not worry about dealing with invalid input data.
Submit two source files for this question as described later.

Question 2 – Instruction Set Architectures [6 marks]
The following instruction needs to be evaluated on different types of architectures.

R = K - (L + M/N) * P

Where R, L, M, N, P are all memory locations (or addresses).

Write assembly programs to evaluate the above expression for the following computer architectures:
(a) One operand instructions
(b) Two operand instructions
(c) Three operand instructions
(d) Zero-address instructions (stack-based)

In addition to usual memory access instructions, assume the following arithmetic instructions are available: ADD, SUBT, DIV, MULT. For some programs you may need to use temporary memory locations. Label those locations as A, B, C … .
Comment every single instruction of your program, explaining what is happening at that step.

Do not attempt to simplify the expression or rearrange its terms. But of course take care of operator precedence (multiplication and division first, followed by addition and substraction).

Rationale
This assessment task will work towards assessing the following learning outcome/s:
• be able to define and appropriately use computer systems terminologies.
• be able to describe the essential elements of computer organisation and discuss how the elements function.
• be able to describe the basic instruction set architecture of a simple computer.
• be able to discuss various programming tools available and their relationship to the computer architecture and
This assessment item covers topics 4 and 5, and has been designed to ensure that you are engaging with the subject content on a regular basis.

Similar Posts

Order Now

Latest Reviews

Facebook

Payments And Security