Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C programming Assembly Code help There are three functions, main() , foo() , bar() . main() calls function foo() and foo() calls function bar(). Dump

C programming Assembly Code help

There are three functions, main(), foo(), bar(). main() calls function foo() and foo() calls function bar().

Dump of assembler code for function main:

0x0000000000400537 <+0>: push %rbp

0x0000000000400538 <+1>: mov %rsp,%rbp

0x000000000040053b <+4>: sub $0x10,%rsp

0x000000000040053f <+8>: mov $0x4,%esi

0x0000000000400544 <+13>: mov $0x0,%edi

0x0000000000400549 <+18>: callq 0x4004e1

0x000000000040054e <+23>: mov %eax,-0x4(%rbp)

0x0000000000400551 <+26>: mov $0x0,%eax

0x0000000000400556 <+31>: leaveq

0x0000000000400557 <+32>: retq

Dump of assembler code for function foo:

0x00000000004004e1 <+0>: push %rbp

0x00000000004004e2 <+1>: mov %rsp,%rbp

0x00000000004004e5 <+4>: sub $0x20,%rsp

0x00000000004004e9 <+8>: mov %edi,-0x14(%rbp)

0x00000000004004ec <+11>: mov %esi,-0x18(%rbp)

0x00000000004004ef <+14>: mov -0x14(%rbp),%eax

0x00000000004004f2 <+17>: cmp -0x18(%rbp),%eax

0x00000000004004f5 <+20>: jne 0x4004fe

0x00000000004004f7 <+22>: mov $0x0,%eax

0x00000000004004fc <+27>: jmp 0x400535

0x00000000004004fe <+29>: mov -0x14(%rbp),%eax

0x0000000000400501 <+32>: mov -0x18(%rbp),%edx

0x0000000000400504 <+35>: sub %eax,%edx

0x0000000000400506 <+37>: mov %edx,%eax

0x0000000000400508 <+39>: mov %eax,-0x4(%rbp)

0x000000000040050b <+42>: mov -0x4(%rbp),%eax

0x000000000040050e <+45>: mov %eax,%edi

0x0000000000400510 <+47>: callq 0x4004cd

0x0000000000400515 <+52>: mov %eax,-0x8(%rbp)

0x0000000000400518 <+55>: mov -0x14(%rbp),%eax

0x000000000040051b <+58>: lea 0x2(%rax),%edx

0x000000000040051e <+61>: mov -0x18(%rbp),%eax

0x0000000000400521 <+64>: mov %eax,%esi

0x0000000000400523 <+66>: mov %edx,%edi

0x0000000000400525 <+68>: callq 0x4004e1

0x000000000040052a <+73>: mov %eax,-0xc(%rbp)

0x000000000040052d <+76>: mov -0xc(%rbp),%eax

0x0000000000400530 <+79>: mov -0x8(%rbp),%edx

0x0000000000400533 <+82>: add %edx,%eax

0x0000000000400535 <+84>: leaveq

0x0000000000400536 <+85>: retq

Dump of assembler code for function bar:

0x00000000004004cd <+0>: push %rbp

0x00000000004004ce <+1>: mov %rsp,%rbp

0x00000000004004d1 <+4>: mov %edi,-0x14(%rbp)

0x00000000004004d4 <+7>: mov -0x14(%rbp),%eax

0x00000000004004d7 <+10>: add %eax,%eax

0x00000000004004d9 <+12>: mov %eax,-0x4(%rbp)

0x00000000004004dc <+15>: mov -0x4(%rbp),%eax

0x00000000004004df <+18>: pop %rbp

0x00000000004004e0 <+19>: retq

1) What are the value(s) that foo() obtains as arguments from main()? In which registers are they passed?

Give offset(s) from rbp from within foo()'s activation record or give the name(s) of registers.

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

Discuss breakdowns in the negotiations process.

Answered: 1 week ago

Question

=+Understand the fi eld of comparative IHRM.

Answered: 1 week ago