TAs: Sagar Karandikar & Kevin Liston
Due Sunday, September 22nd, 2013 @ 11:59pm
Goals
This assignment will cover MIPS.
Obtaining the Assignment
To copy the hw3 files into your homework directory, go to your hw directory (type git init if it's not already in a git repository) and then type:
$ git pull ~cs61c/hw/03 master
If you are having issues with this, please consult Lab 1: Git and Additional Git Notes.
Exercises
Problem 1: Numbers, numbers everywhere
Fill in the blanks in the text file hw3.txt.
NOTE: Please do not change the format of the text file.
Problem 2: C to MIPS
Translate the given C code into MIPS. Put your answer in binSearch.s
. Some code is provided for testing your solution. When you run binSearch.s
, it will inform you if the search failed.
To run MIPS, you can download MARS here.
/* Assume "int" equates to 1 word (4 Bytes) in MIPS, the array is sorted, and nmin and nmax are in [0,length of array). Also, value is not necessarily an element actually present in the array. */ int binSearch(int value,int list[],int nmin,int nmax) { while(nmax>=nmin) { int nmid = (nmin+nmax)/2; if(list[nmid]>value) { // update max nmax = nmid-1; } else if(list[nmid]<value) { // update min nmin = nmid+1; } else { return nmid; } } return -1; }
Submission Guidelines
Please enter all of your text answers into hw3.txt
and include your solution for Problem 2 in binSearch.s
. Once you finished your assignment, go to the directory containing these two files and type:
$ submit hw3