In this lab, we will try writing and executing a program that finds the minimum of a given set of elements by looping over the set.
The Program Template
Download the source file from here: lab2_template.spim Back to Top
#Assembler Directives .data .word 7 .word 3 .word 17 .word 12 .word 30 .word 2 .word 5 .word 1 .word 16 .word 11 .text .globl main #$s0 contains the address of the first #of the data main: lui $s0, 0x1001 ori $s0,$s0,0 Back to Top
Assume that you have an array of 10 elements with base address in $s0. Append to the template code already given the code necessary to find the minimum value from the array (by iterating over the array) and store that value in register $t0. Note: you are free to use any MIPS assembly and instructions and pseudo instructions that are recognized by Spim, but in order to receive full credit you must use a loop. Back to Top
Once you have saved the program template, you can write the code, assuming that the base address is in $s0. There are 10 elements to be read, and the minimum of those to be found. Details about executing the program can be found in the Lab 1 page. Note: Once you find that you have to make changes to your code, make the changes in a text editor, then reinitialize the simulator [Simulator -> Reinitialize], and load the file again [File->Open]
In order to receive credit for this lab, you must submit your code to the TA, Yuly, via email: ysuvorov@cs.iastate.edu. Paste your code into the body of your email and make sure your subject line is "ComS 321, Lab2"
In this lab, we have implemented a minimum-finding algorithm in MIPS assembly language and executed it.
|