Sale!

CPSC 250 Lab 3 Loops and functions solution

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (4 votes)

Assembly Language Programming

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. CPSC 250 Lab 3

 

  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));

}

CPSC 250 Lab 3