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...
icon
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ą
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. 
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY