1. Introduction
ICO
Computer Organization (CCIT4026)
HKU SPACE Community College
(Lab 05)
Student ID:
Name:
Date:
In this lab, we are going to study the procedure call using MIPS programming. The code you write to satisfy the problem must conform to the procedure calling convention discussed in class. Each main program or function must conform to this convention strictly, and use the stack to save and restore the corresponding register values.
2. Lab Work
Given an array with 10 integers [1000 88 256 -547 90 -199 -2021 8044 0 888], write an assembly program to invert an array of the integers (words), i.e. [888 0 8044 -2021 -199 90 -547 256 88 1000], and find the maximum integer in the array. Finally, print the result as shown in the sample output. Use a loop to repeat the steps of inversion, and define a procedure named ¡°swap¡± to swap the content between two array elements (i.e. use $a0 and $a1 to pass the arguments from the main to the swap procedure). In the swap procedure, call another procedure called ¡°check_max¡±.
Sample Output:
Follow the procedures:
1. Adopt the .data segment as follows
2. Save the file as lab5.asm
3. Assembly the program by clicking Run -> Assemble
4. Run the program by clicking Run -> Go
Original array:
1000 88 256 -547 90 -199 -2021 8044 0 888
New array:
888 0 8044 -2021 -199 90 -547 256 88 1000
The biggest value = 8044
— program is finished running —
1/2
ICO
To facilitate grading of your work, please adopt the .data segment exactly as follows
And use exact label names such as Swap, Check_max as mentioned above and in class
Submission Check List:
1. The program is working correctly on MARS
2. Sufficient program comments in the source code
3. Your name and student ID number at the beginning of the program (as program comments)
4. .data segment is adopted as mentioned above
5. Use of label names as required above
6. Submit your work as ONE SINGLE UNZIPPED .asm file (not PDF or the like this time)
7. Submit To SOUL before deadline
Remarks: The instructor will run your code on MARS with a different set of data. So make sure your .asm file is bug-free and performing its function as required.
2/2