Lab 11 - More Assembler

This lab is NOT submitted.

1) memcopy

Write a C function memcopy that will copy n integers from one array to another. The function should have 3 parameters: the to array, the from array and the integer n.

Generate assembler for this function (using -S -m32) and figure out roughly what it does, including where each variable or parameter is stored and what assembler corresponds to each C statement.

2) Optimized memcopy

Copy the .s file over (using the cp command) to another file and regenerate the assembler, this time optimizing the code using -O along with -S and -m32. Compare the code generated with the two versions. What is different? Why would the optimized code be done the way it is?

3) Other compiler options

The man command in cygwin should give you the documentation for a command. In particular,

   man gcc
will give you a long list of all the gcc options. The space bar displays the next page of options. Pick 2 options from the list of optimization options and run them one at a time to see if you notice any change in the generated code. You may choose one of the -O variants as one your options if you want.