Question

In: Computer Science

Write a program to perform the calculation of the following equation and save the result accordingly:...

Write a program to perform the calculation of the following equation and save the result accordingly:

   f = 5x + 3y + z

Assumptions:

- Registers can be used to represent variables x, y, z, and f

- Initialize x, y, and z to values of your choice. f can be initialized to zero.

- Use comments to specify your register usage and explain your logic

Solutions

Expert Solution

Greetings!!

Code:

.data
x: .word 5
y: .word 3
z: .word 1
f: .word 0

.text

main:

lw $t0,x                                   #load x to t0

mul $t0,$t0,5                          #calculate 5x

lw $t1,y                                   #load y to t1

mul $t1,$t1,3                          #calculate 3y

add $t1,$t0,$t1                        #calculate 5x+3y

lw $t2,z                                   #load z to t2   

mul $t2,$t2,1                          #calculate z

add $t2,$t2,$t1                        #calculate 5x+3y+z

sw $t2,f                                   #store the result to f

addi $v0,$0,10                        #termination

syscall

Output screenshot:

For x=5,y=3 and z=1

f=35(or 23H)

Hope this helps


Related Solutions

Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
Use the Henderson-Hasselbalch equation to perform the following calculation. Calculate the mass of solid sodium acetate...
Use the Henderson-Hasselbalch equation to perform the following calculation. Calculate the mass of solid sodium acetate required to mix with 100.0 mL of 0.10 M acetic acid to prepare a pH 4 buffer. (Ka=1.8x10^-5 for acetic acid)
Write a program to perform the following two tasks: 1. The program will accept a string...
Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and smell the rose". Display the result string. 2. Then...
Write a program to perform the following two tasks: 1. The program will accept a string...
Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and smell the rose". Display the result string. 2. Then...
Write a program fragment (not a complete program) which will perform the following task: The int...
Write a program fragment (not a complete program) which will perform the following task: The int variable m currently contains the number of minutes a basketball player played in their last game. Use an IF statement(s) to print out an appropriate message based on the following: If m is from 35 to 48, print the message "very tired" If m is from 10 to 34, print the message "little tired" If m is from 1 to 9, print the message...
write a program to perform the following in C Your program should prompt the user to...
write a program to perform the following in C Your program should prompt the user to enter ten words, one at a time, which are to be stored in an array of strings. After all of the words have been entered, the list is to be reordered as necessary to place the words into alphabetical order, regardless of case. Once the list is in alphabetical order, the list should be output to the console in order. The program should execute...
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that...
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that takes users' input (weight and Height) and calculates the BMI. If the result is less than 18.5 display "you are underweight", if the result is greater than 18.5 display "you have a normal weight", if the result is greater than 24.9 display "your weight is considered overweight", and the result is greater than 30 display "your weight is considered as obese" (BMI = 703...
Write a program to perform the following actions: the language is Java – Open an output...
Write a program to perform the following actions: the language is Java – Open an output file named “Assign14Numbers.txt” – Using a do-while loop, prompt the user for and input a count of the number of random integers to produce, make sure the value is between 35 and 150, inclusive. – After obtaining a good count, use a for-loop to generate the random integers in the range 0 ... 99, inclusive, and output each to the file as it is...
C++. Write a program that uses for loops to perform the following steps: a. Prompt the...
C++. Write a program that uses for loops to perform the following steps: a. Prompt the user to input two positive integers. variables: firstNum and secondNum (firstNum must be less than secondNum). Validate the user's input; prompt the user again if firstNum is not less than secondNum (use for loop). b. Output all odd numbers between firstNum and secondNum. (use for loop). c. Output the sum of all even numbers between firstNum and secondNum. (use for loop). d. Output the...
Program Description Write and test a MASM program to perform the following tasks: Display your name...
Program Description Write and test a MASM program to perform the following tasks: Display your name and program title on the output screen. Display instructions for the user. Prompt the user to enter three numbers (A, B, C) in descending order. Calculate and display the sum and differences: (A+B, A-B, A+C, A-C, B+C, B-C, A+B+C). Display a closing message. Program Requirements The program must be fully documented and laid out according to the CS271 Style Guide. This includes a complete...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT