Question: Using the MARIE computer assembly language, write a program that computes the following expression: z = ( a * b ) * ( c *

Using the MARIE computer assembly language, write a program that computes the following expression:
z =(a * b)*(c * d)* e. The computer will read in the input values a, b, c, d, and e from the keyboard,
and the final result (z) has to be displayed. In addition, every time an input value is read in, it must be
validated by checking that the input is a positive number. If it is positive display the number on the
screen; otherwise display zero and end the program. Each time a multiplication of two numbers is needed,
it has to be done using a multiplication subroutine. Remember that the MARIE instruction set does not
have an instruction to execute multiplication, you must create a subroutine (function) that multiplies two
numbers and call it each time you need it. The program must be tested in the MARIE simulator.
This is a sample of how the could Needs to be.
ORG 100
> input values of 5 variables. a, b, c, d, e
> this would be about 5 lines for each input if you do input validation right away
{
[input]
[output]
[store]< this for each variable
[skipcond 800]< this is if you do your input validation right away
[jump (error loop)]< also only here if you do input validation right away
}(x5)
> now you want to feed each part of the multiplication for the subroutine. i would suggest you work on your subroutine first
{
[load a]
[store (var1)]
[load b]
[store (var2)]
[jns mySubroutine]
~code goes to subr~
~comes back~
[load (x)]
[store (res1)]
}
> you'd want to do this for each multiplication
> var1= never changes and it is passed to the subr
> var2= also doesnt change and it is passed to the subr
> x = unused variable set to 0 where you'll store result of each multiplication (var1*var2). keep in mind you'd reuse x, so you have to store its result in another variable (res1) to preserve the value. think of x as a temp variable
> res1= variable for result 1. so you should have res1(a*b), res2(c*d), res3(res1* res2), and res4(res3* e)
> after this chunk of the code, the subr is actually pretty easy you have have done it in 2 assignments before
{
[mySubroutine, HEX 0]
[clear](reset variable used in the loop)
[store (x)]
^this part of the code sets the address for the subroutine when you called earlier on your code & when you call it after the actual mult loop
recall that the JnS instruction stores the address of the next instruction after it was called
[myMultLoop,...
...
...
]
> this is your multiplication loop (recall var1 and var2 in this example for your loop)
[jump myMultLoop](if var2!=0)
[jumpI mySubroutine](address of mySubroutine)
}
[now here you can have your error loop for input validation]
[maybe a loop for halt? up to you how you implement that part]
> variable declarations
[a, DEC 0]...etc
Use MARIE Simulator to ensure the code works.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!