CSE logo University of Washington Department of Computer Science & Engineering
 CSE 378, Winter 2007
 Machine Organization and Assembly Language Programming
  CSE Home  About Us    Search    Contact Info 

 Academic (Mis)Conduct
 Course wiki
 Mailing list
 Lectures and readings
 Lab hours
 Your Grades
Anonymous Feedback
 Submit Feedback
 Read Feedback
Printable view

Homework #3: Procedure Call

Out: Wednesday, 1/17/2007
Due: Wednesday, 1/24/2007


Consult this Wiki page to post a question, or to help others out by answering a question.

Optional Extra Credit Assignment

An additional assignment can be done for small extra credit, once the assignment described on this page has been completed. The extra credit assignment is described here.

Assignment Overview

This assignment makes sure that you understand the purpose and implementation of procedure call linkage mechanisms, and tries to help bridge from understanding the details of one specific convention to understanding the fundamental issues all must face, but making you familiar with two conventions. (0 is 0, 1 is 1, and 2 is infinity, in some cases.) Specifically, it asks you to replace the subroutine linkage used by the Cebollita compiler with the MIPS convention, as described in Section 2.7 of the text. (In particular, we will use the specific MIPS linkage depicted in Figure 2.16.)


hw3Files.tar.gz contains the sample application used in lecture (main.c and max.c), as well as the result of compiling those files using Cebollita (main.s, and max.s), and finally some "library routines" (prologue-os.o and iolib-os.o). There is also a makefile, with targets a.exe (to build), run (to build if necessary, and to run), and clean. To extract these files:
$ tar xzf hw3Files.tar.gz

Cebollita of course uses the Cebollita subroutine linkage conventions when compiling. Your task is to modify the assembler files (.s files) so that the call to max() from main() uses the MIPS convention instead. This involves modifying a small amount of code in main.s (what the caller does) and in max.s (what the callee does). When done, max() can only be called from code that uses the MIPS conventions. main is a bit more schizophrenic: it uses the MIPS conventions when invoking max(), but continues to follow the Cebollita conventions when invoking printInt() and as a called procedure itself (i.e., in its entry and exit code).

The .s files you start from have been hand commented, to make the sometimes murky code emitted by the compiler a little easier to deal with.Note that it would be a mistake to compile the .c files, since that would overwrite the assembler code files with uncommented versions of the same instructions, and would obliterate any work you had done on a solution. To help prevent this from happening accidently, the .c files have been purposefully renamed in a way that makes compiling them by accident very unlikely.


  • Cebollita conventions

  • MIPS conventions:
  • Section 2.7 of the text, and specifically Figure 2.16.
  • Section A.6 of the text
  • Turnin

    In the directory containing main.s and max.s, use the command 'turnin -ccse378 main.s max.s' to submit the assignment.

    Creative Commons License
    This work is licensed under a Creative Commons Attribution-Share Alike 2.5 License.
    Department of Computer Science & Engineering
    University of Washington
    Box 352350
    Seattle, WA  98195-2350
    (206) 543-1695 voice, (206) 543-2969 FAX
    [comments to zahorjan]