Question
2. Test two versions of swap functions below (by printfing two values, i and j, before and after each function call) and explain why their
2. Test two versions of swap functions below (by printfing two values, i and j, before and after each function call) and explain why their behaviors are different by dumping and comparing the assembly code of two versions of swap functions (GCC provides -S compilation flag option to generate assembly code. Use - m32 gcc flag to get 32-bit assembly code (you are likely to get 64-bit assembly code by default). Note that you need to write a main function that calls and tests these functions. Submit the followings 1) a printeds hard copy of your code, 2) a printed copy of assembly code with important machine instructions commented and expained. Important instructions mean ones that play a key role in explaining the difference, 3) a written paragraph explaining the difference.
void swap1(int i, int j) f void swap2 (int *i, int *j) int t = i; i=j; j=t; int t=i; *j = t; void swap1(int i, int j) f void swap2 (int *i, int *j) int t = i; i=j; j=t; int t=i; *j = tStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started