Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

int sum(int n){ int i=0; int s=0; for(int i=0; i

int sum(int n){

int i=0; int s=0; for(int i=0; i<= n; i++){ s=s+i; }

printf("The sum of first %d numbers is %d. ", n,s); }

Disassembly of section .text:

0000000000000000 : 0: 48 83 ec 08 sub $0x8,%rsp 4: 89 fe mov %edi,%esi 6: b8 00 00 00 00 mov $0x0,%eax b: ba 00 00 00 00 mov $0x0,%edx 10: 39 f0 cmp %esi,%eax 12: 7f 07 jg 1b 14: 01 c2 add %eax,%edx 16: 83 c0 01 add $0x1,%eax 19: eb f5 jmp 10 1b: bf 00 00 00 00 mov $0x0,%edi 20: b8 00 00 00 00 mov $0x0,%eax 25: e8 00 00 00 00 callq 2a 2a: 48 83 c4 08 add $0x8,%rsp 2e: c3 retq

Study the generated assembly and find out what registers are used to store variables i and s of the code in sum.c. Explain your reasoning.

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

What is the difference between alpha testing and beta testing?

Answered: 1 week ago

Question

Why are ratios and trends used in financial analysis?

Answered: 1 week ago