Computer Science 281

Exercise Set #7

Purpose

Due:  

Probable worth: 10 pts. each

Problem 1:

The program ~matthews/cs281/amultmain.c is a main program calling an assembly language subroutine to multiply two 3-by-3 matrices and place the result in a third 3-by-3 matrix.  Please write the assembly language subroutine and place it in a file named amult.s (or amult.m if you include macro directives).

Problem 2: 

The program ~matthews/cs281/linkedlistmain.c (to be discussed in lecture Thursday, 4/11/02) is a basic linked list program written in C.  The program incorporates a record structure:


struct StudentRec  {
char SName[12]; /* one extra for alignment */
int exam1, exam2, exam3;
int avg;
struct StudentRec *next;
};

with space for a student name, three exam scores, an exam average (integer), and a link to the next student record.  The link list head points to a sentinel record with a student name consisting of "ZZZZZZZZZZ" which is only there to announce the start and the end of the list (and does not contain any data to process or print out).  The file linkedlistmain.c will (after Thursday's lecture) contain a call to an assembly language routine 'process' which should go through the linked list record by record and calculate the average exam grade and insert it into the record structure, continuing on to the next element in the linked list.  The new file (currently hidden in 281/working) also contains a 'printname' routine which can be called from an assembly language program to chart progress.  We will look at both files in Thursday's lecture and I will make the copy currently in the working directory into the cs281 directory at that time.

Write an assembly language program for the 'process' routine, placing the program in linkedlist.s (or linkedlist.m).  Be careful to recall that a call to the divide routine may change the value of global registers.  I found it convenient to save the value of the list header and the current record pointer on the stack before calling the divide routine, and to compare the current record pointer to the list header to determine if I was done.

Further note:  As indicated above, you should feel free to start using the macro preprocessor for your assignments.  I will pick up both .m and .s files when I pick up programs, and run the preprocessor on the .m files.

Any questions?  Please ask!