Question: Here is the program you will manipulate: .text main: # Prompt user to input non-negative number la $a0,prompt li $v0,4 syscall li $v0,5 #Read the

Here is the program you will manipulate:
.text main: # Prompt user to input non-negative number la $a0,prompt li $v0,4 syscall li $v0,5 #Read the number(n) syscall move $t2,$v0 # n to $t2 # Call function to get cube_sum #n move $a0,$t2 move $v0,$t2 jal cube_sum #call cube_sum (n) move $t3,$v0 #result is in $t3 # Output message and n la $a0,result #Print C_ li $v0,4 syscall move $a0,$t2 #Print n li $v0,1 syscall la $a0,result2 #Print = li $v0,4 syscall move $a0,$t3 #Print the answer li $v0,1 syscall la $a0,endl #Print ' ' li $v0,4 syscall # End program li $v0,10 syscall #int cube_sum(int n){int sum = 0; #for(int i = 0; i
bne $t0, $zero, exit #body of for loop move $a0, $s1 jal cube add $s2, $s2, $v0 #sum += cube(i) #end of for loop addi $s1, $s1, 1 j for exit: move $v0, $s2 #returning sum lw $ra,0($sp) #restoring return address from stack lw $s0,4($sp) #restoring first saved register from stack lw $s1,8($sp) #restoring second saved register from stack lw $s2,12($sp) #restoring third saved register from stack addi $sp,$sp,16 jr $ra #int cube(int n){ # return n*n*n; #} cube: #compute the cube of a number mul $t0, $a0, $a0 mul $t0, $t0, $a0 move $v0, $t0 jr $ra .data prompt: .asciiz "This program calculates the sum of cube sequence. Enter a non- negative number less than 100: " result: .asciiz "C_" result2: .asciiz " = " endl: .asciiz " "
In this assignment, you will execute and manipulate a simple program written in MIPS assembly language. The code of this program that calculates the sum of cubes of integers from one to a given non-negative integer can be found in the following .asm file: cubesum.asm In this program, function with label cube gets an input n and returns n3. Also, function with label cube_sum gets an input n and returns the following sum with the help of cube function: i=1ni3 To execute this file, you need to use QtSpim application. Please read the following tutorial on QtSpim: Tutorial on Using QtSpim.pdf Alternatively, you can use this online service to run the program. Tasks Here are the tasks that you need to do: 1. (20 points) Execute the given program, input number 9 through console, and find the program output printed on console. Take a snapshot of the value of all the 32 MIPS registers before and after executing the program. The values are visible on the main window of your QtSpim program. 2. (20 points) Manipulate the program assembly code so that it implements and prints out the return value of this function (instead of cube_sum): int sum_odd_factorial(int n){ \{ int sum =0; for(int i=1;i=0;j) if(j \% 2=0) rv+=(i+j); else rv+=(2i3j); 5. (20 points) Execute the program that you wrote in step 4 for input 20. Take a snapshot of the value of all the 32 MIPS registers before and after executing the program. Deliverables You need to submit a zip file compressing the following files: - asm file of the program for task \#2 - asm file of the program for task \#4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
