Question: Assembly code to C This problem involves reverse engineering of a switch statement from assembly code. (It could also be done from disassembled object code

Assembly code to CAssembly code to C This problem involves reverse engineering of a switch

This problem involves reverse engineering of a switch statement from assembly code. (It could also be done from disassembled object code with a bit more work, including using the GDB debugger to inspect the content of the jump table.) In the following procedure, the body of the suitch statement has been removed: long svitch prob(long x, long n) long result x svitch(n) / Fill in code here / return result; Following is the assembly code for the procedure (compiled with -01). Remember that param eters x and n will be passed in registers %rdiand %rsi, respectively. file "switch prob2-soln.c'" text globl svitch prob type witch-prob, function svitch_prob: LFBO: cfi_startproc subq $60, %rsi cnpq $5, %rsi ja .L2 section .rodata align 8 align 4 L7: quad .L3 quad .L2 quad .L3 quad L quad L5 quad .L6 text leaq 0(.xrd1,8), ret %rax movq %rdi, %rax sarq $3, %rax ret novq %rdi, '.rax salq $4, %rax subq %rdi, %rax movq %rax, Xrdi inu1q%rdi, %rdi L2: %rax leaq 75(%rdi), ret cfi endproc LFEO: size switch-prob, "-switch-prob ident "GCC: (Ubuntu/Linaro 4.6,3-1ubuntu5) 4.6.3" section .note.GNU-stack,",progbits Fill in the body of the switch statement with C code that will have the same behavior as the assembly code

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!