Question: Name: Note: Post your submission to ICS 2 3 2 D 2 L site on or before the due date. Programming Assignment 2 : The
Name:
Note: Post your submission to ICS DL site on or before the due date.
Programming Assignment :
The purpose of this project is to gain a greater understanding of the Intel bit instruction set and understand how a compiler translates C code into assembly language. By compiling the program in unoptimized mode you will hopefully see a fairly clear translation. When running in optimization mode, you will see how well compilers can optimize your code.
To compile an unoptimized version use:
gcc Waadhln g masmintel m "Project c "Project gasm"
This will write the unoptimized intermixed source and assembly code Project gasm.
To compile an optimized version use:
gcc Waadhln O masmintel m "Project c "Project oasm"
This will write the optimized intermixed source and assembly code Project oasm.
The Waadhln option causes gcc to generate intermixed source and assembly code.
The masmintel option causes gcc to generate assembly code in intel format.
The m generates bit code.
The g option generates unoptimized code while O generates optimized code.
The web site Godbolt.org can also be used to compile the program. Make sure you use the correct compiler options as shown above.
The generated code includes quite a few directives that can be ignored. Most of the directives begin with a period There are also a few call instructions to procedures that you may not know what they mean that can be ignored. For example:
call xgetpcthunk.bx
add ebx, OFFSET FLAT:GLOBALOFFSETTABLE
In all of the following questions, the line numbers refer the line numbers in the C code.
The following questions should be answered using the unoptimized code.
Describe the stack at line return sum; The bottom of the stack is the first row below. The top of the stack will be the last item. The first few items are provided. You will probably need to add some additional rows to the table below.
Description Value
First argument to main argv
Second argument to main argc
Return address of main Callers return address
C runtime value of bp Callers bp register
Local variable i in main bp
In detail explain the code generated for line k functioni j; For this and all further questions in which you are asked to explain the code generated in detail, I expect you to copy the generated code and add a comment for each line. For example:
e CFC mov DWORD PTR ebp ; initialize i
You can also refer to WeekCAssemblygasm for examples of what you should submit.
In detail explain the code generated for functionline through
In detail explain the code generated for functionline through
The following questions should be answered using the optimized code.
In detail explain the code generated for functionline through Why does this work?
How are function calls optimized? For example, see lines and
The following questions should be answered using by comparing the unoptimized code and the optimized code.
Compare the code generated by function in the unoptimized and optimized versions. Explain the optimizations.
Bonus points
In detail explain the code generated for function This a hard. Try your best. Why is the compiler doing this? You need to explain the purpose of each line of the generated assembly code.
Bonus points
The file strlen.asm contains the Microsoft Visual Studio source code for the strlen function. You need to explain the purpose of each line of the assembly code particularly lines through
Grading Criteria By Project Items:
Stack contents not defined well enough points
Call functon description points
Code description for function not complete enough points
Code description for function not complete enough points
Optimized function description incomplete points
Optimized function call description incomplete points
Function optimized description incomplete points
Late Submission Policy:
points if submitted after the due date and an extension has been granted.
points if submitted after the due date and an extension has not been granted.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
