

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Project; Class: INTRO TO COMPU ORGNZN; Subject: COMPUTER DESIGN/ARCHITECTURE; University: University of Florida; Term: Unknown 1989;
Typology: Study Guides, Projects, Research
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Date assigned: September 23, 2008
Due date: October 7, 2008 (11:59 pm)
Primary TA: Zhuo HUANG ([email protected])
1. Overview
The purpose of this assignment is to implement the Binary Search using the MIPS assembly language, and to simulate your program in SPIM (the MIPS simulator). You should comment your code as well as simulate it as described in the simulation section. You will be required to submit your comment code and the results of your simulation by the due date above.
2. Binary Search A fast way to search a sorted array is to use a binary search. The idea is to look at the element in the middle. If the key is equal to that, the search is finished. If the key is less than the middle element, do a binary search on the first half. If it's greater, do a binary search of the second half.
The binary search procedure must return the position if found, and ‐ 1 if not found.
The sample code of Binary search is as follows:
BinarySearch(A[0..N-1], key, low, high) { if (high < low) return -1 // not found mid = (low + high) / 2 if (A[mid] > key) return BinarySearch(A, key, low, mid-1) else if (A[mid] < key) return BinarySearch(A, key, mid+1, high) else return mid // found }
3. Requirements 3.1. Your code must have one main procedure and one binary search procedure. It can have more procedures if needed. 3.2. The code contains one array that holds 16 sorted integers and one integer named “key” as input. The output should be stored in another integer named “position”.
3.3. For binary search procedure (See discussion slides “MIPS Programming(2)” for details about procedures):
a. You must use “jal” to call a procedure.
b. All needed parameters (such as key, low, high and the array/variable addresses) must be passed as arguments by using a0‐a3 or stack.
c. You need to save all necessary registers.
d. It must follow the “binary search” concept. Don’t implement other search mechanisms.
3.4. Good comments are required. In particular:
a. Include a comment block at the top of your program of the form
b. All procedures must have a register map, which described which registers are be ing used by the procedure and their symbolic meaning. c. When it would enhance the understandability of the code, prefix a block of state ments with a comment describing the purpose of that block. d. Each and every assembly statement must be given a good comment that describ es the semantic meaning of the operation being performed (restating the syntac tic meaning doesn’t count). addi $t4, ‐ 4 # $t4 ‐= 4 BAD! addi $t4, ‐ 4 # count ‐= 4 GOOD!
3.5. All assignments must be submitted through E‐Learning system. No late submission will be accepted. You are required to submit the MIPS code (in .s format) and, if necessary, a text file (in the format of txt, word, or pdf) explaining the steps you take to implement the program. Please make sure that your submitted file can be opened on CISE windows machines.
3.6 All homework must be done individually.
4. Hints. Read discussion slides “MIPS Programming(2)” carefully.