Laboratory Exercises For Computer Science 211

Lab to Compare RISC- and CISC-Based C-Compilers

Lab to Compare RISC- and CISC-Based C-Compilers

Goals: This laboratory provides some experience reviewing VAX assembly language and invites comparisons between approaches used by C compilers for VAX and HP machines. The lab invites you to speculate on how these comparisons for VAX and HP computers might generalize to CISC and RISC machines.

Resources: Two VAX manuals are placed in the MathLAN lab, Science 2417, for reference.

Steps for this Lab: Work for this lab is based on the C program array.c, which reads real numbers into an array, sorts the data using both a Bubble Sort and a Quicksort, checks the two sorts produce the same results, and prints the sorted data.
  1. On the HP machines, program array.c is found in directory ~walker/211/labs. Copy array.c to your account, read through the listing to familiarize yourself with what the program does, and compile and run the program a few times to check you understand the output.

  2. On the HP machines, compile the program to optimized assembly language, and answer the following general questions:

    1. Where are the global variables stored?
    2. Where are the local variables for main and for each sorting routine stored?
    3. What work is required for a procedure call, and what code is used to accomplish this task?
    4. What values are passed for the array and integer parameters, and how are these parameters communicated during a procedure call?
    5. What differences or similarities can you identify between calls to a non-recursive procedure and a recursive procedure?
    6. How are data elements within the array referenced?
    7. How are branches based upon real or integer comparisons accomplished?

  3. On the VAX, the program is found in directory [walker]. Copy array.c to your account. Compile and run this program on the VAX using the following commands:
    
         cc array
         link array
         run array
    
    Check that the VAX program produces the same results as the HP code.

  4. On the VAX machines, compile the program to optimized assembly language using the following command:
    
         cc/optimize/machine_code/lis array
    
    Answer the general questions from Step 2 for this listing.

  5. Change the code on each machine, so that the arrays are declared locally within main rather than as globals. How does this change affect the assembly language? (E.g., how is space allocated for this data, where is that space, and how are specific data elements referenced?)

  6. In comparing the assembly language for this C program on the two machines, describe any significant similarities and any significant differences you can observe. (Ignore differences in the format of the assembly language, and focus only on the actual assembly language.)

  7. Speculate on how much differences found in the assembly language reflect idiosyncrasies of the individual compilers and how much these differences reflect the underlying architecture.


Work to be turned in:


This document is available on the World Wide Web as

     http://www.math.grin.edu/~walker/courses/211/labs/lab.risc-cisc.html

created November 12, 1997
last revised November 12, 1997