CPSC250 Lab 3:  Loops and functions

$30.00

Category: Tags: , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (5 votes)

Purpose

Learn to develop assembly language programs using loops and function calls

 

What to Hand In

Completed Sum2.asm, PosRun.asm, Fib.asm

 

  1. Modify the MIPS program Sum.asm from Lab#2 to have a function perform the addition operation: int add2 (int num1, int num2). (Don’t have to use the stack for this problem)

 

  1. The file posrun.cpp contains a simple C++ function that finds the length of the longest consecutive run of positive values in an array, convert the C++ program to a MIPS assembly program.

 

  1. Write a MIPS program with a recursive function that calculates the Fibonacci sequence. Your program should prompt the user for the starting sequence number. The high-level C code for the sequence is:

 

int fib (int n)

{

if(n == 0) {

return 1;

}

if (n == 1) {

return 1;

}

return (fib(n – 1) + fib(n – 2));

}