Assignment 3 for Assembly Programming | CDA 3100, Assignments of Electrical and Electronics Engineering

Material Type: Assignment; Professor: Zhang; Class: COMPUTER ORG I; Subject: COMPUTER DESIGN/ARCHITECTURE; University: Florida State University; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 08/30/2009

koofers-user-iu7
koofers-user-iu7 🇺🇸

8 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework Assignment #3 – MIPS Assembly Programming
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 $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.asm”
(http://www.cs.fsu.edu/~zzhang/CDA3100_Spring_2009_files/test_palindrome.asm).

Partial preview of the text

Download Assignment 3 for Assembly Programming | CDA 3100 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Homework Assignment #3 – MIPS Assembly Programming

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).