average: xorq trax, trax * sum = 0 xorg trcx, trcx labe12 labell: addą (šrdi, šrcx, 8), $rax * sum = sum + a[i] #i - 1+1 incą trcx label2: cmpa $8, trcx labell salq $3, trax # sum sum / 8 retą
average: xorq trax, trax * sum = 0 xorg trcx, trcx labe12 labell: addą (šrdi, šrcx, 8), $rax * sum = sum + a[i] #i - 1+1 incą trcx label2: cmpa $8, trcx labell salq $3, trax # sum sum / 8 retą
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Need help with computer science question
![Suppose we have the following C function:
long average (long a 0) { // finds the average (arithmetic mean of an array of 8 elements
long sum = 0;
for (int i = 0;
sum += a[i):
i < 8;
i++) (
// loop through all elements
}
return sum/8; // find the average by dividing by the number of elements (8).
}
In the assembly implementation of the function below, fill in the three missing jump instructions so that it matches the code above:
average:
xorg trax, trax
xorg trcx, trcx
# sum = 0
* i = 0
label2
labell:
# sum = sum + a[i]
# i = i+1
addą (šrdi, trcx, 8), &rax
incq trcx
label2:
cmpg $8, trcx
labell
salq $3, trax
# sum = sum / 8
retą](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F522630ab-9263-4897-b338-a0fdea344135%2F321914b6-a31b-4b5d-bfdc-f1863a905903%2Fsq1efab_processed.png&w=3840&q=75)
Transcribed Image Text:Suppose we have the following C function:
long average (long a 0) { // finds the average (arithmetic mean of an array of 8 elements
long sum = 0;
for (int i = 0;
sum += a[i):
i < 8;
i++) (
// loop through all elements
}
return sum/8; // find the average by dividing by the number of elements (8).
}
In the assembly implementation of the function below, fill in the three missing jump instructions so that it matches the code above:
average:
xorg trax, trax
xorg trcx, trcx
# sum = 0
* i = 0
label2
labell:
# sum = sum + a[i]
# i = i+1
addą (šrdi, trcx, 8), &rax
incq trcx
label2:
cmpg $8, trcx
labell
salq $3, trax
# sum = sum / 8
retą
Expert Solution

Step 1
In computer programming, assembly language, sometimes abbreviated asm, is any low-level
programming language in which there is a very strong correspondence between the instructions
in the language and the architecture's machine code instructions.
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY