Question: You are expected to compare the source code and assembly code for the following C code. (You can get the assembly code with usually the

You are expected to compare the source code and assembly code for the following C code. (You can get the assembly code with usually the s flag). Can you see any optimizations that can be done on the assembly code?

int a=1, b=2, c=3;

int proc1 (int a, int b, int c)

{

if (a > 0)

return b c;

else

return b + c;

}

int main()

{

int w, x, y;

w = proc1 (a, b, c);

switch (w) {

case 0: x = 3; break;

case 1: x = 4; break;

case 2: x = 7; break;

default: x = 9; break;

}

y = w + x;

return 0;

}

Report:

Please include your (wellcommented) assembly code and your explanation of what this program does and how the assembly code can be optimized. Include your test results with several screenshots.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!