Question

In: Computer Science

Computer Architecture: Write a MIPS program to compute f = g - (f + 5) Assume...

Computer Architecture:

Write a MIPS program to compute f = g - (f + 5)
Assume registers $to, $s1 hold values for g and f respectively.
The program should display the following prompts and read value entered by the user “Enter a value for f:"
“Enter a value for g:"
The program the prints: "Answer for f = g - (f + 5):"
The program should repeat the above steps 3 times for each input pair, f and g

Make certain that your assembly code is properly organized (indented, commented, contains your name at the top of the code). Comment any assumptions at the top and include results showing the working code via screen prints

Solutions

Expert Solution

Dear Student,

I hope the following code fits in your needs.

# Space left to add name of the student

.data
    msg1: .asciiz "Enter a value for f: "
    msg2: .asciiz "\nEnter a value for g: "
    result: .asciiz "\nAnswer for f = g - (f + 5): "

.text
    li $t2,5
    li $t3, 0
    li $t4, 3
    Loop:
        beq $t3, $t4, Exit
        # Taking input from user for f
        li $v0,4
        la $a0,msg1
        syscall
        li $v0,5
        syscall
        # moving the value of $v0 to $s1
        move $s1,$v0
        # Taking input from user for g
        li $v0,4
        la $a0,msg2
        syscall
        li $v0,5
        syscall
        # moving the value of $v0 to $t0
        move $t0,$v0
        # calculating the value of the given formula
        Add $t1,$s1,$t2
        sub $s1,$t0,$t1
        li $v0,4
        la $a0,result
        syscall
        li $v0,1
        move $a0,$s1
        syscall
        j Loop     #jumps back to the top of loop
    Exit:       # ends the program
        li $v0,10
        syscall

Note: The out snapshot is to be taken by the student after adding their name.

Thank you, please upvote if you liked it!


Related Solutions

Write MIPs program that will read two integers from the user and compute for the sum...
Write MIPs program that will read two integers from the user and compute for the sum and difference of the two integers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".
Write MIPs program that will read two intergers from the user and compute for the sum...
Write MIPs program that will read two intergers from the user and compute for the sum and difference of the two intergers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g,...
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively   B[8] = A[i-j]; 2.Translate the following C code to MIPS assembly code. Assume that the values of v in $a0, k in $a1, temp in $t0.    // leaf procedure that...
Write a MIPS program to check if computer is a big-endian or little-endian system. This must...
Write a MIPS program to check if computer is a big-endian or little-endian system. This must be done in MIPS assembly language.
Computer Architecture and Organization(c++) Write a C++ program that prompts the user to enter a hexadecimal...
Computer Architecture and Organization(c++) Write a C++ program that prompts the user to enter a hexadecimal value, multiplies it by ten, then displays the result in hexadecimal. Your main function should a) declare a char array b) call the readLn function to read from the keyboard, c) call a function to convert the input text string to an int, d) multiply the int by ten, e) call a function to convert the int to its corresponding hexadecimal text string, f)...
Write a program to compute the root of the function f(x) = x3 + 2 x2...
Write a program to compute the root of the function f(x) = x3 + 2 x2 + 10 x - 20 by Newton method ( x0 =2 ). Stop computation when the successive values differ by not more than 0.5 * 10-5 . Evaluate f(x) and f '(x) using nested multiplication. The output should contain: (1) A table showing at each step the value of the root , the value of the function,and the error based upon successive approximation values...
Write a complete ARM asembly program for following code: g=12, h=8, i=2, j=5; f = (g...
Write a complete ARM asembly program for following code: g=12, h=8, i=2, j=5; f = (g + h) - (i + j); Your program displays the message: f = (g + h) – (i + j) = 13 Note that 13 should be calculated, not hardcoded Below is my current code: .global _start _start: mov R0,#12 mov R1,#8 mov R2,#2 mov R3,#5 add R4,R0,R1 add R5,R2,R3 sub R6,R4,R5 How should I display the message: "f = (g + h) –...
(a) (f ∘ g)(3) (b) g(f(2)) (c) g(f(5)) (d) (f ∘ g)(−3) (e) (g ∘ f)(−1) (f) f(g(−1))
(a)    (f ∘ g)(3) (b)    g(f(2)) (c)    g(f(5)) (d)    (f ∘ g)(−3) (e)    (g ∘ f)(−1) (f)    f(g(−1))  
a) write a program to compute and print n, n(f), f(f(n)), f(f(f(n))).........for 1<=n<=100, where f(n)=n/2 if...
a) write a program to compute and print n, n(f), f(f(n)), f(f(f(n))).........for 1<=n<=100, where f(n)=n/2 if n is even and f(n)=3n+1 if n is odd b) make a conjecture based on part a. use java
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction): Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction Performs the bitwise AND operation on the operands stored...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT