Question: Please correct me if I ' m wrong or not. thank you. For a C function switch hw 5 below and the assembly code along

Please correct me if I'm wrong or not. thank you.
For a C function switch hw5 below and the assembly code along with a jump table, fill in the missing
parts of the C code. See page 233 and Practice Problem 3.31 on how the labels in case statements and the
Jump Table can be related.
(a) C Code
void switch_hw5(long a, long b, long c, long *dest)
{
long val;
switch(a){
case 0 :
val =b-a;
break;
case 1:
c=(a4)+a;
/* Fall through */
case 3 :
val =-1c;
break;
case 5:
case 7:
val=(a+c)4;
break;
default:
val=a+b;Jurp Trable can be nclated.
(a) C coda
1
lone val;
wattch(a) i
cane a:
val = b-a;
break;
case 1:
c=(aces)+ a;
f" rall throuph "f
case 3:
val =-1nc;
break;
case 5 :
case 7:
val =(a+c)334
brak;
default:
val =a+b;
}
return val;
(b) Maxembly Code
weitch has:
.L.1:
mevq Xrds, Xraxs
subq Tirdi, Sirax
.15:
ret
movq Sirat, Siruts
salq $4, tirds
addq Srat, Trate
. L.6:
movq Srrts, Sraze
xart $-1, tal
ret
.17:
Inaq (Tirdx, Irat), tiras
sarq $4, Niras
ret
Inaq (Ardi,rat), Trax
ret
(c) Jump Table
. L4:
.quad .13
.quad .15
.quad .12
suad .16
.quad .12
.quad .17
quad .12
.quad .17
}
return val;
}
 Please correct me if I'm wrong or not. thank you. For

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!