Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Start by making a copy of this Y 8 6 - 6 4 example darr from class. Copy / paste the contents of the file

Start by making a copy of this Y86-64 example darr from class. Copy/paste the contents of the file into this
simulator G to run/debug. Run/debug the program until you're comfortable with the general structure of the
program, including the main and sum procedures and how they affect registers and memory. In particular, try
making changes to the input array and observing how the output of sum is aggregated in the %rax register using
a loop (and how the loop keeps track of pointers, indices, etc). Please follow up during office hours or on piazza
with questions! Then...
(20) Add a Y86-64 swap procedure equivalent to the following C code. Copy the C code into your Y86-64
program as a comment. Assume that %rdi will hold xp and %rsi will hold yp :
void long ?**xp, long {:?**yp){
long x=?**xp;
long y=?**yp;
?**xp=y;
?**yp=x;
}
Comment each line of your Y86-64 code in terms of xp,yp,x, and y.
(30) Add a Y86-64 sort procedure equivalent to the following C code. Copy the C code into your Y86-64
program as a comment. Assume that %rdi will hold arr and %rsi will hold length; also assume that this
procedure will call your swap procedure above as appropriate:
void sort(long *arr, long length){
long *iPtr = arr; // pointer to arr[i]
for (long i=0;i length -1;++i){
long *minPtr = iPtr; // pointer to smallest value found so far in rest of arr
long ** jPtr = iPtr +1;?? pointer to arr[j]
for (long j=i+1;j length ; ++j){
// update minPtr if array j less than value at minPtr
if jptr **minPtr
}
minPtr = jPtr;
}
++jPtr; // increment array[j] pointer
// swap if a value was found smaller than that at iPtr
if (minPtr != iPtr){
}
swap(minPtr, iPtr);
}
++iPtr; // increment array [i] pointer
}
image text in transcribed

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

More Books

Students also viewed these Databases questions

Question

What is the goal of conservatism?

Answered: 1 week ago

Question

7. How can the models we use have a detrimental effect on others?

Answered: 1 week ago

Question

c) Convert ethyne to the ketone below. Provide the retroanalysis

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago

Question

What are Electrophoresis?

Answered: 1 week ago