Consider the following MARIE Code: 100 If, Load X /Load the first value 101 Subt Y /Subtract…

Question 3 – MARIE Assembly [20 marks]

(a) Consider the following MARIE Code:

100 If, Load X /Load the first value

101 Subt Y /Subtract the value of Y, store result in AC

102 Skipcond 400 /If AC=0 (X=Y), skip the next instruction

103 Jump Else /Jump to Else part if AC is not equal to 0

104 Then, Load X /Reload X so it can be doubled

105 Add X /Double X

106 Store X /Store the new value

107 Jump Endif /Skip over the false, or else, part to the end of if

108 Else, Load Y /Start the else part by loading Y

109 Subt X /Subtract X from Y

10A Store Y /Store Y-X in Y

10B Endif, Halt /Terminate program (it doesn’t do much!)

10C X, Dec 12 /Assume these values for X and Y

10D Y, Dec 20

Find the values stored in the following registers after the execution of “Skipcond 400” instruction: [5 marks]

(i) PC

(ii) IR

(iii) MAR

(iv) MBR

(v) AC

(b) Suppose we add the following instruction to MARIE’s ISA:

JumpIOffset X

This instruction will jump to the address calculated by going to address X, then adding the value found there to the value in the AC. Show how this instruction would be executed using RTN. [5 marks]

(c) Write a MARIE program to allow the user to input 8 integers (positive, negative, or zero) and then find the smallest and the largest and print each of these out.

As an example, if the user enters the following decimal numbers as input (one after the other)

23, -6, 78, 0, 36, 3, -250, –5

the program would output the following values as the maximum and minimum, respectively:

78
-250

Assume that the user will always provide valid numbers as input; that is, do not worry about dealing with invalid input data.

Write comments within your program so that a reader can understand it easily. [10 marks]

Looking for a similar assignment? Get help from our qualified experts!

"Our Prices Start at $9.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!":

Order a Similar Paper Order a Different Paper