Starting from:

$30

CS224-Lab 2 Creating and Running Simple MIPS Assembly Language Programs Solved

Preliminary Report/Preliminary Design Report

Part 1 (Preliminary Report/Preliminary Design Report: Learning the principles of writing subprograms. Bit manipulation. Dynamic storage allocation.

 

Lab Work:

Part 2  More on learning principles of writing subprograms. Involves dynamic storage allocation and arrays.

 

 

Part 1. Preliminary Work / Preliminary Design Report 

You have to provide a neat presentation prepared by Word or a word processor with similar output quality such as Latex as you were asked in Lab 1. At the top of the paper on left provide the following information and staple all papers. In this part provide the program listings with proper identification like Part no. and program number/name in that part

 

a. Circular Shifts:
Shift Left Circular (SLC): Implement a method (subprogram) called shiftLeftCircular that shifts the contents of a register and works as demonstrated below:

# input  8 hex digits (shift left amount) == output 8 hex digits

0XAA 00 00 BB (SLC   4) == 0XA0 00 0B BA

0XAA 00 00 BB (SLC  8) ==  0X00 00 BB AA

As shown above the bits falling down from left comes to right in the order they drop.

 

Shift Right Circular (SRC): Implement a method (subprogram) called shiftRightCircular. It works like SLC but this time the bits falling down from right comes to left in the order they drop.

 

Write two separate subprograms for these circular shift operations. Provide the necessary interface for testing  your code in the main (top level) program. Ask the user to enter the decimal integer number to be shifted and a number that indicates the amount of shift. Display the number to be shifted, the shift amount and direction, and the shifted number in hexadecimal on the console.

 

You must pass the number to be shifted and the shift amount in $a0, and $a1 respectively and return the result in $v0 (as required by the rules of MIPS software development).

 

How to display an integer in hexadecimal: See Mars help menu on syscalls.

 

Make sure that you have an efficient implementation.

 

b. Array Processing: The main program invokes two subprograms: createArray and arrayOperations.
 

createArray: Asks the user the array size and  initializes the array elements with interaction on the console. It returns to the main program the array beginning address and size respectively in  $v0 and $v1.

 

arrayOperations: Receives array address and array size from the main program respectively in $a0 in $a1 and invokes min, max, sum,  palindrome subprograms to perform the following. After each it displays a console message.

min: returns the minimum value stored in the array.
max: returns the maximum value stored in the array..
sum: returns the summation of array elements.
palindrome: Checks if array contents defines a palindrome. An array that contains for example 1, 4, 4, 1 is a palindrome. An array with zero or one element is a palindrome by definition. The method returns 1 in $v0 if it is a palindrome, otherwise it returns 0.
 

Part 2. Lab Work: Writing MIPS assembly language programs 

 initializeArray: Main program invokes a subprogram (initializeArray) and initializes an array of integer numbers with random numbers within the range of 1 to 100,000. See Syscalls help menu item of Mars for random number generation. The subprogram gets the array size from the user.
 

2. bubbleSort: Main program invokes a subprogram (bubbleSort) that sorts the array in ascending order using the bubble sort algorithm. The array size can be 0 or more.
 

3. processArray: Main program invokes another subprogram and passes the sorted array. This subprogram (processArray) displays the sorted array by providing array index position, array element value, summation of the digits of the element (using a method called sumDigits), and indicates if the element is a prime number or not (using a method called checkPrime). Therefore, for each array element it generates one line with four items. For example, if the array position 5 contains 25 it displays
5             25           7             No

More products