Question: 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

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 _____: val = _______________________; break; case _____: c = _______________________; /* Fall through */ case _____: val = _______________________; break; case _____: case _____: val = _______________________; break; default: val = _______________________; } return val; } (b) Assembly Code switch_hw5: .L3: movq %rdx, %rax subq %rdi, %rax ret .L5: movq %rsi, %rdx salq $4, %rdx addq %rsi, %rdx .L6: movq %rdx, %rax xorb $-1, %al ret .L7: leaq (%rdx,%rsi), %rax sarq $4, %rax ret .L2: leaq (%rdi,%rsi), %rax ret (c) Jump Table .L4: .quad .L3 .quad .L5 .quad .L2 .quad .L6 .quad .L2 .quad .L7 .quad .L2 .quad .L7 

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!