Objectives • Run moderate to complex MIPS assembly language programs. Learn how to use arrays in assembly programming. L

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Objectives • Run moderate to complex MIPS assembly language programs. Learn how to use arrays in assembly programming. L

Post by answerhappygod »

Objectives Run Moderate To Complex Mips Assembly Language Programs Learn How To Use Arrays In Assembly Programming L 1
Objectives Run Moderate To Complex Mips Assembly Language Programs Learn How To Use Arrays In Assembly Programming L 1 (122.69 KiB) Viewed 57 times
Objectives • Run moderate to complex MIPS assembly language programs. Learn how to use arrays in assembly programming. Learn how to use functions in assembly programming. • Understand the use of stack and stack pointers in assembly programming. 1. Each number in the Fibonacci series is the sum of the previous two numbers. The table below lists the first few numbers in the series, fib(n). n 1 2 3 4 5 6 7 8 9 10 11 fib(n) 1 1 2 3 5 8 13 21 34 55 89 a) Write a function called fib in a high-level language that returns the Fibonacci number for any nonnegative value of n. Hint: You probably will want to use a loop. Clearly comment your code. b) Convert the high-level function of part (a) into MIPS assembly code. Add comments after every line of code that explain what it does. Use the QtSpim simulator to test your code on fib(3), fib(7), fib(11). Output your results to the console. Fibonacci series, fo .fi .f2..., is defined by: fr = fn-1 + fn-2 Initial Conditions: fo=0,fi=1 2. Consider the following C code snippet. // C code void setArray(int num) { int i; int array[10; for (i = 0; i <10; i =i+1) { arrayli) = compare(num, i); } } int compare(int a, int b) { if (sub(a, b) >=0) return 1; else return 0; } int subſint a, int b) { return a-b; } a) Write a complete program in MIPS assembly language to implement the C code snippet. The program should receive an integer num from the console and output the number to result to the console as well. Use $s0 to hold the variable i. Be sure to handle the stack pointer appropriately. The array is stored on the stack of the setArray function. b) Assume setArray is the first function called. Draw the status of the stack before calling setArray and during each function call. Indicate the names of registers and variables stored on the stack, mark the location of Ssp, and clearly mark each stack frame.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply