CS202 - Assignment Six

Due: 2016-04-08 10:10 Note the date and time

Objectives

Warm-up [10 points]

Do Bryant problem 3.58

Some x86-64 assembly

For the most part, we don’t have much call to actually write assembly – it is generally more useful to be able to read it and figure out what it does. However, I would like you to get a taste for it, so we are going to write a couple of functions out by hand.

To help you out, I am providing you with a stub file that handles the setup and teardown for the assembly and a driver file that calls the functions from C. I am also giving you a header file. I’ve not talked about writing header files much in class, though we did briefly look at headers for some of the standard libraries. As we saw, they contain function prototypes – just the definition of the functions including parameters and return types. These are used by the compiler to figure out how to use the function (what kind of parameters we are expecting to be pushed on the stack and what kind of return value we are expecting). This helps it generate the assembly and it also gives us a sanity check that we are calling the function the right way. We’ve not needed to write header files for own work, but they become necessary as soon as you have more than one file (as we will in this case).

The driver file is not actually one of your deliverables. It is an example of how you can use the assembly in a C program. You are welcome to write your own driver for testing (for example, one that just calls one of the following functions or has hard coded values inside). You could, for example, write individual C programs for each of the problems that test a variety of inputs for you.


Turning in your work

Please submit the first part as username_hw6A.c and the second as username_hw6_asm.s on Moodle. I do not need the driver code or the header file.