
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: Assignment; Professor: Zhang; Class: COMPUTER ORG I; Subject: COMPUTER DESIGN/ARCHITECTURE; University: Florida State University; Term: Spring 2009;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

CDA 3100, Computer Organization I, Spring 2009 Due: Beginning of the class on February 20, 2009 Submission: Email the code to the TA. A hard copy of the code along with the answers of the questions should also be submitted. The purpose of this assignment is to let you be familiar with assembly programming using MIPS. It is recommended that you test the code using SPIM. ¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾ Problem 1 (40 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 called ``set’’. 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/~zzhang/CDA3100_Spring_2009_files/test_set.asm). Problem 2 (60 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 $a 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.asm” (http://www.cs.fsu.edu/~zzhang/CDA3100_Spring_2009_files/test_palindrome.asm).