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...
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...
Write a program in c++ that can perform encryption/decryption. In the following let the alphabet A...
Write a program in c++ that can perform encryption/decryption. In the following let the alphabet A be A={A, a, B, b, . . ., “ ”, “.”,“’ ”}. The encoding is A→0, a→1, B→2, b→4, . . ., Z→50, z→51, “ ”→52, “.”→53 and “’”→54.
Write a program in java that can perform encryption/decryption. In the following let the alphabet A...
Write a program in java that can perform encryption/decryption. In the following let the alphabet A be A={A, a, B, b, . . ., “ ”, “.”,“’ ”}. The encoding is A→0, a→1, B→2, b→4, . . ., Z→50, z→51, “ ”→52, “.”→53 and “’”→54.
Who knows to do this topic with python code? Write a program to perform the following...
Who knows to do this topic with python code? 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT