In the C function that follows, we have omitted the body of the switch statement. In the

Question:

In the C function that follows, we have omitted the body of the switch statement. In the C code, the case labels did not span a contiguous range, and some cases had multiple labels.

void switch2(short x, short *dest) { short val = 0; switch (x) { } Body of switch statement omitted } *dest =

In compiling the function, gcc generates the assembly code that follows for the initial part of the procedure, with variable x in %rdi:

1 2 3 4 5 void switch2 (short x, short *dest) x in %rdi switch2: addq cmpq ja jmp $2, %rdi $8, %rdi .L2 *. L4

It generates the following code for the jump table: 1 .L4: 2 3 34 5 6 7 8 9 10 .quad . quad .quad - quad

Based on this information, answer the following questions:

A. What were the values of the case labels in the switch statement?

B. What cases had multiple labels in the C code?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Systems A Programmers Perspective

ISBN: 9781292101767

3rd Global Edition

Authors: Randal E. Bryant, David R. O'Hallaron

Question Posted: