Mips Labs Using SPIM - Lab 3


In this lab, we will write and execute a program that will copy a given array into another.

Table of Contents

The Program Template
      Analysis of the Program Template
Filling in the Program
Executing the Program
Turning In Your Code
Conclusion




The Program Template


Download the source file from here: lab3_template.spim


Back to Top

Analysis of the Program Template


#Lab 3: Copy the elements of an array into another.

#Assembler Directives
.data
.word 7
.word 3
.word 1
.word 12
.word 10
.word 2
.word 5
.word 9
.word 16
.word 11
.text
.globl main

main:
add $s0, $zero, $zero
add $t0, $zero, $zero
#$s0 contains the address of the first element of the first array
lui $s0, 0x1001
ori $s0,$s0,0
#$t0 contains the address of the first element of the second array
lui $t0, 0x1001
ori $t0, $t0, 0x0040
 

 
Back to Top

Filling in the Program


Assume that you have an array of 10 elements with base address in $s0. Assume that the base address of the second array is in $t0. Copy the elements from the first array to the second. In order to receive full credit you must use a loop to traverse the elements of the arrays.

Back to Top

Executing the Program

 

Once you have saved the program template, you can write the code, assuming that the base address of the source array is in $s0 and the base address of the destination array is in $t0. 

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]

Back to Top

Turning In Your Code

Turn in your code by emailing it to the TA, Yuly, at ysuvorov@iastate.edu. The subject line of your email should be "Comp Sci 321 Lab 3" and you should paste the assembly code into the message body - no attachments please.

Back to Top

Conclusion

In this lab, we have implemented an algortihm to copy a fixed number of elements from one array into another.

Back to Top

Valid HTML 4.01! No Gifs! Lynx Enhanced!