CSci223 - Spring 2005

Programming Assignment #4

Writing Functions in Assembly


In class on Monday, March 28th, I will give some "hints" about how to do this assignment. If you miss class that day, please get the notes from someone in the class.


For your fourth programming assignment you will be implementing four numerical functions in assembly. This assignment is intended to get you more familiar with how computers operate at a low level. Students will receive a zero if their assembly is found to have been generated by a compiler.

The starter code includes a test program written in C, as well as a (mostly) empty file for your assembly. There is also a Makefile. Again, your program should compile when you type "make".

Since you're programming in assembly, your functions won't really have function prototypes that show the number and type of parameters they take and what type they return. However, your functions should work correctly when called using the prototypes listed below. The test program uses these conventions. You may certainly modify the test file to add more testing code, but do not change the interfaces used to call the functions. If you have questions about this, please see your instructor.

int square( int );

This function should return the square of its argument. It should work for all negative and non-negative numbers.

int gcdi( int, int );

This function should iteratively find the greatest common denominator of it's two arguments using an iterative algorithm. (No recursion.) It should work for all negative and non-negative numbers. See the previous Knuth handout for GCD details.

int gcdr( int, int );

This function is the same as above, but recursion must be used.

int lcm( int, int );

This function should return the LCM of its two arguments. It should work for all negative and non-negative numbers.

void sort( int[] a, int length ); (Extra Credit)

Students may implement this function for 10 points of extra credit. The entire assignment is worth 100 points. The array should be sorted in place. It doesn't matter which sorting algorithm you use.

This assignment will be graded according to the Programming Assignment #4 Grading Sheet. Any solutions that don't compile on onyx using the supplied Makefile will receive a healthy deduction.

This assignment is due by class time on Monday, April 4th. It will be considered late at 11:00am on Tuesday, April 5th. Any solutions received after graded solutions have been distributed to the class will receive a zero.

Students should submit their solutions by email to the instructor. They should only submit the assembly.s file.

Please review the Honor Code section of the syllabus and be sure you are familiar with the applicable documents.