In: Computer Science
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication.
Note: If any of the input values a, b, and c is a negative numbers or a zero, then the result printed should be “0”. Otherwise, the result of the multiplication must be printed.
ANSWER:--
GIVEN THAT:--
INPUT /Input Variable a
STORE a /Store variable a
OUTPUT /Display Variable a
INPUT /Input Variable b
STORE b /Store variable b
OUTPUT /Display Variable b
INPUT /Input Variable c
STORE c /Store variable c
OUTPUT /Display Variable c
/ Loop for performing iterative addition and giving
res=a*b
loop1, LOAD res
ADD a
STORE res
Load b
SUBT one
STORE b
SKIPCOND 400 /Is multiplication is completed?
JUMP loop1 /if No,then repeat loop1 Again and if Yes,Exit the
loop1
/ Again,Loop for performing iterative addition and
giving z=res*c=a*b*c
loop2, LOAD z
ADD res
STORE z
LOAD c
SUBT one
STORE c
SKIPCOND 400 /Is multiplication is completed?
JUMP loop2 /if No,then repeat loop2 Again and if Yes,Exit the
loop2
LOAD z /Load the final result to varable z
OUTPUT /Print final Answer i.e.Variable z=a*b*c
HALT /Stop the program
/Declaring variables used in program
a, DEC 0
b, DEC 0
c, DEC 0
z, DEC 0
one, DEC 1
res, DEC 0
END