Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed

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 = t

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions