In this lab, we will write and execute a program that will copy a given array into another.
The Program Template
Download the source file from here: lab3_template.spim Back to Top
#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
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
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]
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.
In this lab, we have implemented an algortihm to copy a fixed number of elements from one array
into another.
|