cc
and
gcc
respectively. For both compilers, you should use the
-S
option (as mentioned by Appel) to get assembly
language output. (This will go in a file named like your C input file
but with the ending changed from .c to .s, unless you specify
a different output filename using the -o
option.) For
both compilers, you should use the option -O2
to enable
optimization. For gcc, you should additionally use -mgp32
to specify 32-bit code, rather than the default of 64. (This isn't
really essential, but will make the code from the two compilers more
directly comparable and also make the code more familiar relative to
MC48.)
x
isn't used at all, and hence eliminate it
entirely. To avoid this, we can pass x
rather than
y
in the first call to f
. We can also make
the use of x
prior to the call more exciting. This
results in the following alternative code:
void g(void); void h(int); int f(int a){ int b; b = a + 1; g(); h(b); return b + 2; } void h(int y){ int x; for(x = y + 1; x < 100; x += x) ; f(x); f(2); }
Instructor: Max Hailperin