Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(PLEASE COMPLETE ALL QUESTIONS AND ORGANIZE THE ANSWER BY QUESTION./ PLEASE PROVIDED THE SCREENSHOTS FOR QUESTIONS 1,3,5/ THE CODE TO MANIPULATE IS AT THE BOTTOM)

(PLEASE COMPLETE ALL QUESTIONS AND ORGANIZE THE ANSWER BY QUESTION./ PLEASE PROVIDED THE SCREENSHOTS FOR QUESTIONS 1,3,5/ THE CODE TO MANIPULATE IS AT THE BOTTOM)

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 (extension of assembly files may be .s as well).

In this program, function with label cube gets an input and returns. Also, function with label cube_sum gets an input and returns the following sum with the help of cube function: =13.

To execute this file, you can use this online service (https://shawnzhong.github.io/JsSpim/), or alternatively, install and use the QtSpim application. Please read the following tutorial on QtSpim: Tutorial on Using QtSpim.pdf

Tasks

Here are the tasks that you need to do:

QUESTION 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 the online assembler or the QtSpim program.

QUESTION 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 <= n;i+=2)

sum += factorial(i);

return sum;

}

where factorial is another function that you need to implement:

int factorial(int n)

{

int rv = 1;

for(int i = 1; i <= n;i++)

rv *= i;

return rv;

}

QUESTION 3 (20 points) Execute the program that you wrote in step 2 for input 11. Take a snapshot of the value of all the 32 MIPS registers before and after executing the program.

QUESTION 4 (20 points) Manipulate the program assembly code so that it it implements and prints out the return value of this function:

int nested_loop_test(int n){

int rv = 1;

for(int i = 1; i < n;i*=2)

for(int j = i; j >=0; j--)

if(j % 2 == 0)

rv += (i + j);

else

rv += (2*i-3*j);

return rv;

}

QUESTION 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 (20 points)

.asm file of the program for task #4 (20 points)

A report.pdf file containing all the snapshots (30 points) and console outputs (30 points) of tasks #1, #3, and #5.

total: 100 points.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions

Question

5. Prepare for the role of interviewee

Answered: 1 week ago

Question

6. Secure job interviews and manage them with confidence

Answered: 1 week ago