0% found this document useful (0 votes)
36 views1 page

List of Programs

The document provides examples of MiniMIPS programs for various tasks like if-else statements, while loops, finding the largest integer in a list, writing procedures to find the maximum of three integers and perform selection sort, and finding the length and sum of the maximum-sum prefix in a list.

Uploaded by

Vimoli Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

List of Programs

The document provides examples of MiniMIPS programs for various tasks like if-else statements, while loops, finding the largest integer in a list, writing procedures to find the maximum of three integers and perform selection sort, and finding the length and sum of the maximum-sum prefix in a list.

Uploaded by

Vimoli Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

MiniMIPS Programs

1. Write sequence of MiniMIPS instructions corresponding to the following if-then-else statement:


if (i<=j) x = x+1; z = 1; else y = y–1; z = 2*z
2. Write sequence of MiniMIPS instructions corresponding to the while statement:
while (A[i] == k) i = i + 1;
3. Show a sequence of MiniMIPS instructions that perform the function of the following loop
loop: i = i + step;
sum = sum+ Ali);
if (i t n) goto loop;
4. List A is stored in memory beginning at the address given in $s1. List length is given in $s2. Find the
largest integer in the list and copy it into $t0.
5. Write a procedure that accepts three integer parameters and returns the maximum amongst them.
6. Write a procedure that performs selection sort to sort given set of numbers.
7. Consider a list of integers of length n. A prefix of length i for the given list consists of the first i integers
in the list, where 0 ≤ i ≤ n. A maximum-sum prefix, is a prefix for which the sum of elements is the largest
among all prefixes. For example, if the list is (2, -3, 2, 5, -4), its maximum-sum prefix consists of the first
four elements and the associated sum is 2- 3+2+5 =6; no other prefix of the given list has a larger sum.
Write a MiniMIPS program to find the length of the maximum-sum prefix and the sum of its elements for
a given list.

You might also like