Answered step by step
Verified Expert Solution
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 Y example darr from class. Copypaste the contents of the file into this
simulator to rundebug Rundebug 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...
Add a Y swap procedure equivalent to the following code. Copy the code into your Y
program as a comment. Assume that rdi will hold and rsi will hold :
void long long :
long ;
long ;
;
;
Comment each line of your Y code in terms of and
Add a Y sort procedure equivalent to the following C code. Copy the C code into your Y
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 sortlong arr long length
long iPtr arr; pointer to arr
for long ; length ;
long minPtr iPtr; pointer to smallest value found so far in rest of arr
long jPtr iPtr pointer to arr
for long ; length ; j
update minPtr if array less than value at minPtr
if jptr
minPtr jPtr;
jPtr; increment arrayj pointer
swap if a value was found smaller than that at iPtr
if minPtr iPtr
swapminPtr iPtr;
iPtr; increment array i pointer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started