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.
-
Richard A. Brunner, Editor, Vax Architecture Reference Manual, Second
Edition, Digital Press, 1991.
-
VAX MACRO and Instruction Set Reference Manual, Digital Equipment
Corporation, May 1993.
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.
-
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.
-
On the HP machines, compile the program to optimized assembly language, and
answer the following general questions:
-
Where are the global variables stored?
-
Where are the local variables for main and for each sorting routine
stored?
-
What work is required for a procedure call, and what code is used to
accomplish this task?
-
What values are passed for the array and integer parameters, and how are
these parameters communicated during a procedure call?
-
What differences or similarities can you identify between calls to a
non-recursive procedure and a recursive procedure?
-
How are data elements within the array referenced?
-
How are branches based upon real or integer comparisons accomplished?
-
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.
-
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.
-
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?)
-
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.)
-
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:
-
Discussion and answers to questions for steps 2, 4, 5, 6, 7.
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