Upload a pdf file containing your solutions to the problems below to Learning Suite before 11:00pm on the assigned date.
You're free to use this website for the homework problems. It's an online Y86-64 simulator that allows you to step through assembly code, checking registers, memory and status codes along the way.
Problem 4.47: Let's start with a big-picture observation: the easiest way to get from any C program to a working Y86-64 version of the same is to (a) alter the C code so it maps to the Y86-64 instruction set more efficiently, and then (b) hand translate the x86-64 assembly code that GCC produces into Y86-64 assembly code. Part A of this problem corresponds to (a) above: by revising the code to use pointers rather than array accesses, GCC's output will be closer to what you can do in the Y86-64 instruction set. When you think you have a pointer version that works, naturally you'll want to test it to ensure that the two versions of the code are equivalent before going on to the next step. Use something along the lines of the test code available here to make sure that both versions of the bubble sort function are equivalent. Your submission should include not only the C code in your new version of the function, but results from testing that show that the functions are equivalent.
The next step is to compile your source code (using the "-S" command line argument to GCC) and hand translate the bubble_p() function to Y86-64 code. Experiment with different optimization levels and choose a version of assembly code that will require the least amount of work to turn into Y86-64 code. Use the Y86-64 code framework here so you can run and test your solution using Y86-64 simulation tools. (Note that the data to be sorted in this code is the same as in the C test code above.)
Finally, run your code using the yas and yis programs (a Y86-64 assembler and instruction set emulator, respectively) that can be obtained by clicking here. Place the file tools.tar into a newly created directory and type "tar xvf *". This will create a tools subdirectory and place in it all the files required to build yas and yis. Now type "cd tools" and then type "make" and new yis and yas executables should be built. If your Y86-86 code is in the file bubble.ys in the parent directory, you can assemble it by typing "tools/yas bubble.ys" and then you should run the resulting object file on the simulator by typing "tools/yis bubble.yo". (Check the README file in the tools directory for a bit more information about the yas and yis programs.) In creating any Y86 program for the yis simulator, bear in mind that the largest allowed memory address is 0x0FFFF.
Make sure the results of execution are as you expected. Include the simulator output from the execution of your program in your submission with some brief annotation that explains how you know it is correct.
Problem 4.51: No C code or execution results are required.