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 bc 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
input values of variables. a b c d e
this would be about lines for each input if you do input validation right away
input
output
store this for each variable
skipcond this is if you do your input validation right away
jump error loop also only here if you do input validation right away
x
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 var
load b
store var
jns mySubroutine
~code goes to subr~
~comes back~
load x
store res
you'd want to do this for each multiplication
var never changes and it is passed to the subr
var also doesnt change and it is passed to the subr
x unused variable set to where you'll store result of each multiplication varvar keep in mind you'd reuse x so you have to store its result in another variable res to preserve the value. think of x as a temp variable
res variable for result so you should have resab rescd resres res and resres e
after this chunk of the code, the subr is actually pretty easy you have have done it in assignments before
mySubroutine HEX
clearreset 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 var and var in this example for your loop
jump myMultLoopif var
jumpI mySubroutineaddress 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 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
