

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
Information about homework #3 for the computer organization i course at florida state university. The assignment focuses on mips assembly programming and includes five problems and an extra credit problem. Students are required to translate a c function to mips assembly, write functions for a palindrome checker and median finder, and write a disassembler for mips instructions. All programs should be tested using spim, the mips assembler and simulator. Submission is in hardcopy format.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CDA 3100, Computer Organization I, Fall 2007 Department of Computer Science, Florida State University ¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾ Points: 100 (4 % of the total grading) Due: Beginning of class on October 3, 2007 The purpose of this assignment is to let you be familiar with assembly programming using MIPS; all the programs should be tested using SPIM, the MIPS assembler and simulator. Submission: Hardcopy required; for each problem, turn in a hard copy of your program along with running results for test cases. Problem 1 (15 points) Exercise 2.47 (p. 1153). Problem 2 (20 points) Exercise 2.15 (p. 149). Problem 3 (15 points) Below is a C (C++) function. int set(int a[], int n, int v) { int i; i = 0; do { a[i++] = v; } while (i < n); return i; } Translate this function to an equivalent function in MIPS assembly. You need to follow the MIPS calling convention and others should be able to call and use your function. In other words, the address of the array a should be passed in register $a0, the value of n is passed in as register $a1, and the value of v is passed in as register $a2 (in other words, the MIPS calling convention is used). You need to test your program using “test_set.s” (http://www.cs.fsu.edu/~liux/courses/cda3100/assignments/test_set.s). Problem 4 (25 points) Write a MIPS function (called “palindrome”) that returns 1 if the input string is a palindrome and returns 0 otherwise. The address of the string will be passed in $a0 and the value should be returned in $v0. Here a string is a palindrome if it reads the same in forward or backward direction (including white spaces, punctuation marks, and so on, but is case insensitive (i.e., ‘A’ and ‘a’ are considered to be the same)). Note the string is ended with ‘\0’ (C/C++ convention). You need to test your program using “test_palindrome.s” (http://www.cs.fsu.edu/~liux/courses/cda3100/assignments/test_ppalindrome.s). Problem 5 (25 points) Write a MIPS function (called “compute_median”) that computes the median of a set of nonnegative integer values. The address of the array will be passed in register $a0, and the number of elements will be passed in register $a1 and the median should be returned in register $v0. Note that the median is the middle value when sorted; if there are an even number of values, then the median is the average of the two middle values (rounding off if the result is not an integer). Note that the
input array is not necessarily sorted. You need to test your program using “test_median.s” (http://www.cs.fsu.edu/~liux/courses/cda3100/assignments/test_median.s) Extra Credit Problem 6 (15 points) Write a disassembler function for MIPS instructions on Fig. 2.10 (p. 71) in MIPS assembly, assuming that the instructions are given at memory location given in $a0 and the number of instructions is given in $a1. For each recognized instruction, it should print the corresponding assembly on the console and your program should report an error of “Unknown instruction” if an instruction is not any of the ones given in Fig. 2.10. You need to demonstrate that your program works on the instructions given in Fig. 2.10 and report an error for any other instructions. Note that the instructions are a subset of the ones given in Fig. 2.27, the encoding of which is available at http://www.cs.fsu.edu/~liux/courses/cda3100/assignments/examples-fig2-27.hex.