Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

How is slaked lime powder prepared ?

Answered: 1 week ago

Question

Why does electric current flow through acid?

Answered: 1 week ago

Question

What is Taxonomy ?

Answered: 1 week ago

Question

1. In taxonomy which are the factors to be studied ?

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago