CS220 – General Instructions (Solution)

$ 29.99
Category:

Description

• You can use QtSpim simulator to work on these assignments.
• Only one member of each group has to submit the assignment. Please Make sure that there is no duplicate submission from your group.
• The assignments have to be submitted through CANVAS.
• Sharing of the solution outside the group is strictly prohibited. If found guilty, both the involved groups will get 0 in the assignment.
Q 1: (5 points) Write a MIPS Assembly Language program that is equivalent to the following C function:
int func (int x, int y)
{ int u;
u = -5 * x – 7 * y;
if (u < -35) return -35; else if (u > 35) return 35; else return u; }
Q 1: (5 points) Write a MIPS program to convert a user given integer to a binary number. Consider both the positive and negative integers. In case of a negative integer, the output has to be in 2’s complement form. Print the binary number as a string.
Q 2: (5 points) Write a MIPS program to add two rational numbers and print the result in normalized scientific format with two digits after the decimal point ((+/-)X.YYe(+/-)ZZ). The numerators and denominators of the two numbers are given as inputs by a user.
Example:
Inputs: ,
Output: 4.24e+01
Q 1: (5 points) The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …. Any number in the series is found by adding up the two numbers before it.
Write a MIPS program to perform the following: Given a positive integer 0 ≤ n ≤ 20, store the first n numbers of the Fibonacci series in memory and print them.
Q 2: (5 points) Write a MIPS program that given a number N and N integers can print the integers in a sorted order using Bubble Sort. Bubble Sort algorithm involves swapping of two numbers. Write a procedure for swapping two numbers separately and use it in the sort function.
Q 1: (5 points) Binary Search is an algorithm to search a value in a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty. (NIST
Definition)
Suppose that a sorted array of positive integers is stored in the memory. Write a MIPS program that accepts a positive integer from a user and returns the leftmost index of the element in the array if the element is present in the array. Otherwise, the program returns 0.
Q 2: (5 points) Write a MIPS program to multiply two matrices. The two matrices are stored in the memory as two dimensional array in row-major order. The elements of the matrices are given in double-precision floating point format. Store the result matrix in the memory and print it.

Reviews

There are no reviews yet.

Be the first to review “CS220 – General Instructions (Solution)”

Your email address will not be published. Required fields are marked *