COSC-2425 Programming Project Four One of the very practical uses of assembly language pro- gramming is its ability to optimize the speed and size of computer programs. While programmers do not typically write large-scale applications in assembly language, it is not uncommon to solve a performance bottle neck by re- placing code written in a high level language with an as- sembly language procedure. In this programming project you will be given a C++ pro- gram that generates an array of pseudorandom integers and sorts the array using the selection sort algorithm. Your job is to write an assembly language procedure that also sorts the array of pseudorandom integers using the selection sort algorithm. The C++ program will time multi- ple repetitions of the sort performed by both the C++ code and your assembly language procedure. The C++ program will compare the result. If all goes as expected, your as- sembly language procedure should be faster than the C++ code. Chapter 13 of your textbook contains a discussion of how to interface an assembly language procedure with a high- level programming language like C++. The Visual Studio solution for the C++ program that you are given has been packaged and compressed into a file called "Project Four.zip". Create a location on your computer for this project. Download the compressed file, "ProjectFour.zip", and unpack it into that location in your computer Look in the unpacked folder for a file named "ProjectYour sin". The "sin" file extension stands for solution. Double clicking on this file will start up the Visual Studio solution for ProjectFour and allow you to execute the C++ program. Modify Project Four by following these steps: 1. Click on the project name, "ProjectFour" in the Solu- tion Explorer pane. 2. Click on the "Project" choice in the menu bar at the top of the screen. 3. Select "Build Customizations". 4. In the Visual C++ Build Customization Files dialog box, check the checkbox next to masm(.tar- gets,.props). Choose OK to save your selection and close the dialog box. 5. On the menu bar, choose "Project", then choose "Add Existing Item". 6. In the Add New Item dialog box, select the file named "AsmSelectionSort.asm". Choose Add to add the file to your project and close the dialog box. Use Ctrl+F5 or click on "Debug" in the Menu Bar followed by "Start Without Debugging" to execute the program. The MASM assembler will assemble AsmSelectionSort.asm into an object file that is then linked into your project. A "stub" assembly language procedure has been provided so that you can execute the C++ program to get a feel for how it works. Your job is to improve on the efficiency of the C++ compiled code by writing an assembly language procedure that is faster. Click on the file named "AsmSelectionSort.asm" in the Solution Explorer pane. This file is your starting point for creating an assembly language version of the selection sort routine. As always, start small. DO NOT be the Cookie Monster and gobble up the whole project at once. Steps you might consider, but are not limited to are: Have your assembly language procedure return the number of elements in the array. This will tell you if what is being passed as an argument is the value you expected. Have your assembly language procedure return the value of the first element in the array. This will tell you if you understand how to address and retrieve the value of an element in the array. Have your procedure return the value of the second (or fifth) element in the array. This will tell you if you understand how to address and retrieve the value of a particular element in the array, This project will provide you with the opportunity to: Link an assembly language procedure to an existing C++ program. Create an assembly language version of a C++ program. Demonstrate your ability to work with a one-dimensional array. Show that you can implement a while loop in assembly language. Demonstrate your ability to implement nested loops in assembly language. Display your understanding of what an assembly language procedure is and how they can be used. Provides a chance for you to show that you understand how to compare values and take conditional action based on the results. -. Observe how assembly language procedures can be used to optimize programs written in a high-level language like C++. do do 1 TITLE AsmSelectionSort Procedure (AsmSelectionSort.asm) 2 3 4 586 model flat, AsmSelectionSort PROTO, arrayPTR:PTR DWORD, count: DWORD .data . code AsmSelectionSort PROC USES edi, arrayPTR:PTR DWORD, count: DWORD ; Performs a selection sort on an array of 32-bit integers. 3 esi, arrayPtr ; Dumny assignment to prevent warning mov ecx, count ; Dummy assignment to prevent warning 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 mov Define a dummy return value. eax, 1 jmp short omega return omega: ret AsmSelection Sort ENDP END