Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the function: int main() { long x; long n; long result = n; switch(x) { /* The code for the cases goes here

Here is the function:

int main()
{ 

long x;

long n;

long result = n; 
switch(x) { /* The code for the cases goes here */ } } 

Here is the assembly code:

(gdb) x/8x 0x4005b8 0x4005b8: 0x00000000004004e6 0x0000000000400516 0x4005c8: 0x00000000004004ed 0x0000000000400502 0x4005d8: 0x0000000000400516 0x0000000000400509 0x4005e8: 0x0000000000400516 0x000000000040050f

Dump of assembler code for function main: 0x00000000004004b6 <+0>: push %rbp 0x00000000004004b7 <+1>: mov %rsp,%rbp 0x00000000004004ba <+4>: mov %rdi,-0x18(%rbp) 0x00000000004004be <+8>: mov %rsi,-0x20(%rbp) 0x00000000004004c2 <+12>: mov %rdx,-0x28(%rbp) 0x00000000004004c6 <+16>: mov -0x18(%rbp),%rax 0x00000000004004ca <+20>: mov %rax,-0x8(%rbp) 0x00000000004004ce <+24>: mov -0x20(%rbp),%rax 0x00000000004004d2 <+28>: sub $0xd,%rax 0x00000000004004d6 <+32>: cmp $0x7,%rax 0x00000000004004da <+36>: ja 0x400516 0x00000000004004dc <+38>: mov 0x4005b8(,%rax,8),%rax 0x00000000004004e4 <+46>: jmpq *%rax 0x00000000004004e6 <+48>: addq $0xd,-0x8(%rbp) 0x00000000004004eb <+53>: jmp 0x40051e 0x00000000004004ed <+55>: mov -0x8(%rbp),%rdx 0x00000000004004f1 <+59>: mov %rdx,%rax 0x00000000004004f4 <+62>: shl $0x2,%rax 0x00000000004004f8 <+66>: add %rdx,%rax 0x00000000004004fb <+69>: add %rax,%rax 0x00000000004004fe <+72>: mov %rax,-0x8(%rbp) 0x0000000000400502 <+76>: addq $0x5,-0x8(%rbp) 0x0000000000400507 <+81>: jmp 0x40051e 0x0000000000400509 <+83>: shlq -0x8(%rbp) 0x000000000040050d <+87>: jmp 0x40051e 0x000000000040050f <+89>: shlq $0x3,-0x8(%rbp) 0x0000000000400514 <+94>: jmp 0x40051e 0x0000000000400516 <+96>: movq $0x0,-0x8(%rbp) 0x000000000040051e <+104>: mov -0x28(%rbp),%rax 0x0000000000400522 <+108>: mov -0x8(%rbp),%rdx 0x0000000000400526 <+112>: mov %rdx,(%rax) 0x0000000000400529 <+115>: pop %rbp 0x000000000040052a <+116>: retq

Objective:

Finish the switch statements, with the correct values, and cases. There are suppose to be 5 cases, and a default case. 0x4004e6 is the address of the smallest value of case where it starts. 0x40050f is the address of the largest value of the case where it starts. 0x400516 is the address of the default case where it starts.

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions