Question

In: Computer Science

Using the MARIE computer assembly language, write a program that computes the following expression: z =...

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.

Solutions

Expert Solution

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


Related Solutions

Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The...
Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The parity checker should repeatedly execute a loop that performs the following tasks: 1. Ask the user for an input X, which can be any printable ASCII character from Table 1; 2. Output the decimal code of X; 3. Output the total number of 1’s that appears in the binary code of X; 4. Output the parity bit which, when added to the binary code...
( Assembly Language ) Write a program that computes the 7th fibonacci number. The fibonacci sequence...
( Assembly Language ) Write a program that computes the 7th fibonacci number. The fibonacci sequence - 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, … what is the initialization of a, b, and d? - a b d 1 ? ? 1 2 ? ? 1 3 1 1 2 4 1 2 3 5 2 3 5 6 3 5 8 7 5 8 13 wrong initialization - a b d 1 0 1 1 2...
Write a MARIE assembly language program that will read an “array” of positive decimal values stored...
Write a MARIE assembly language program that will read an “array” of positive decimal values stored in memory and output the smallest value. Use variable addr to store the location of the first data item. Use variable length to store the number of items in your array. Your code should be organized such that adding an additional array item would only involve adding the data line (ie. 021 dec 400) and updating the length variable (ie. length, dec 5). You...
Exercise #1:  Write MARIE assembly language code to input 3 values into variables x, y, and z,...
Exercise #1:  Write MARIE assembly language code to input 3 values into variables x, y, and z, calculate x + y -z, and outputs the result. Run your code in the simulator and submit a screen shot of your program run and the code. //x + y -z ORG 100     INPUT     STORE X     INPUT     STORE Y     INPUT     STORE Z     LOAD X     ADD Y     SUBT Z     OUTPUT     Halt X, Dec 0 Y, DEC 0 Z, DEC 0 Exercise #2: Write MARIE assembly...
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B)...
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B) - (-C - D) 1. Declare and initialize the memory variable A to 32-bit signed integer value 543210 and variable B to 16-bit signed integer value -3210. 2. Declare the memory variables C and D and read in their values from the keyboard as 32-bit signed integer value 43210 and 8-bit signed integer values -10, respectively. a. You should display a message asking for...
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B)...
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B) - (-C - D) 1. Declare and initialize the memory variable A to 32-bit signed integer value 543210 and variable B to 16-bit signed integer value -3210. 2. Declare the memory variables C and D and read in their values from the keyboard as 32-bit signed integer value 43210 and 8-bit signed integer values -10, respectively. a. You should display a message asking for...
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality:...
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality: Configures pin RA2 of the PIC24to be an output to control an attached LED. Configures pin RB13 of the PIC24 to be an input to read the value on an attached switch (this switch will connect to ground when pressed). Configures pin RB13 to use the internal pull-up resistor. After configuration, the LED will be "off" when the push-button is pressed, and "on" when...
Using C Language Write a program segment that computes 1 + 2 + 3 + ......
Using C Language Write a program segment that computes 1 + 2 + 3 + ... + ( n - 1) + n , where n is a data value. Follow the loop body with an if statement that compares this value to (n * (n + 1)) / 2 and displays a message that indicates whether the values are the same or different. Please give me code to just copy and paste
Write a computer program using C++ that computes the value of a Lagrange Polynomial and accepts,...
Write a computer program using C++ that computes the value of a Lagrange Polynomial and accepts, as input: (n+1) data points (x0, f(x0)), (x1, f(x1)),...(xn, f(xn)).. at value x, which the polynomial is to evaluated. As output, the program should produce a statement that reads, "f(x) = (the value of f(x))". As a test, use the data values (1,2);(-1,1);(0,0);(2,4);(-2,3)
Using the windows 32 framework , write an assembly language program ; write a procedure to...
Using the windows 32 framework , write an assembly language program ; write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT