Using the MARIE computer assembly language write a program t

Using the MARIE computer assembly language, write a program that computes the following expression: z = (a * b) * (c * d). The computer will read in the input values a, b, c, and d 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 displayed on the screen. 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.

Solution

ORG 100 /starting point
Input /Enter the first number
Store Numa /Store the number
Output /Display first number
Input /Enter the second number
Store Numb /Store number
Output /Display second number
Input /Enter third number
Store Numc /display third number
Input /Enter fourth number
Store Numd /display fourth number
Output /Display final multiplied number

Loop, Load Numa /Load the first number and start looping
Add Sum /here sum=0 and sum=sum+Numa
Store Sum
Load Numb /Load the second number which will be used for skipping condition skipcond
Subt One /substracting Numb-1
Store Numb /Store the new Numb
Skipcond 400 /Skip when the second number reaches zero
Jump Loop /Used to repeat addition until second number reaches zero
Load Sum /it is a*b
Store Numa /storing the sum in Numa

Loop1, Load Numc /Load the third number and start looping
Add Sum1 /here sum1=0 and sum1=sum1+Numc
Store Sum1
Load Numd /Load the fourth number which will be used for skipping condition skipcond
Subt One /substracting Numd-1
Store Numd /Store the new Numd
Skipcond 400 /Skip when the second number reaches zero
Jump Loop1 /Used to repeat addition until fourth number reaches zero
Load Sum1 /it is c*d
Store Numc /Storing sum1 in Numc

Loop2, Load Numa /Loading Numa=sum
Add Mulfinal /here Mulfinal=0 and Mulfinal=Mulfinal+Numa
Store Mulfinal
Load Numc /Loading Numc=sum1
Subt One /substracting Numc-1
Store Numc /Store the new Numc
Skipcond 400 /Skip when the Numc reaches zero
Jump Loop2 /Used to repeat addition until Numc reaches zero
Load Mulfinal /it is a*c
Output /Display final multiplication product
HALT

Using the MARIE computer assembly language, write a program that computes the following expression: z = (a * b) * (c * d). The computer will read in the input v

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site