Notice:
Due: Monday Mar. 16th by 4pm
Resources:
MIPS Instruction Reference
MIPS Tutorial Part 5 (Ch 17 - Ch 20):
Week 4 examples
Appendix A.10 in the text
Two files to be submitted:
arrays.s
nested.s
1. Declares an array to hold 30 integers.
2. Uses a loop to initialize the array with the first 30 odd integers.
3. Display the same values to the screen within the loop.
4. Uses a second loop to step through the array and display only those
integers that are evenly divisible by 3 or 7.
Sample output...
$ spim -f arrays.s Loaded: /usr/share/spim/exceptions.s 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 3 7 9 15 21 27 33 35 39 45 49 51 57 $
Do not display anything for the other values in the array. You will need to implement if-else control structures within your loops.
First look at
http://www.cs.csub.edu/~eddie/cmps2240/code/lab4/loops.s
for an example of an if-else control structure inside a loop.
Then look at
http://www.cs.csub.edu/~eddie/cmps2240/code/lab4/loops2.s
for an example of filling an array and then displaying the values
in the array.
(The loops2.s code is closer to what you want your solution to do.)
copy the files to your own lab4 directory like this:
from odin
cp /home/fac/eddie/public_html/cmps2240/code/lab4/* .
from local machine
scp odin.cs.csubak.edu:/home/fac/eddie/public_html/cmps2240/code/lab4/* .
Space
Reread lab 2 if you need a refresher on how to allocate arrays.
Note that an integer requires 4 bytes.
Psuedocode
The psuedocode for your program is this:
Data segment: Allocate space for an array
Text segment: Fill an array with odd integers
and also iterate over the array and display the contents
Iterate over the array and display the elements divisible by 3 or 7
Check Off
Demonstrate to the instructor that your program displays the numbers from
item 2 above, then displays the numbers from item 4 above.
This is worth 5 points.
$ spim -f nested.s . O O O O O O O O O . O O O O O O O O O . O O O O O O O O O . O O O O O O O O O . O O O O O O O O O . O O O O O O O O O . O O O O O O O O O . O O O O O O O O O .
Draft your algorithm in C first, then implement the algorithm in MIPS.
Review
http://www.cs.csub.edu/~eddie/cmps2240/code/lab4/doors.s
for an example of a nested loop structure.
Check Off
Demonstrate to the instructor that your program displays the pattern
above. This is worth 5 points.
Place your lab programs arrays.s and nested.s in the correct directory on odin. directory name: /home/fac/yourname/2240/4/ Replace yourname with your own odin username!