Question: Write a Y86-64 program that sorts an array of longs. (10) Allocate a hardcoded input array like that used by sum-Y86-64.txt (linked in the Examples

 Write a Y86-64 program that sorts an array of longs. (10)

Allocate a hardcoded input array like that used by sum-Y86-64.txt (linked in

Write a Y86-64 program that sorts an array of longs. (10) Allocate a hardcoded input array like that used by sum-Y86-64.txt (linked in the Examples module on Canvas) with at least 10 elements. (20) Implement a swap procedure equivalent to the following C code. Assume that \%rdi will hold xp and %rsi will hold y. Use only caller-saved registers (e.g., \%rax, %rcx, %rdx) to hold x and y : - Copy the C code above into your Y86-64 file as a comment for the procedure. Also write out the C code in goto-label format to aid in translating the loops to Y86-64. Finally, note that the Y86-64 encoding doesn't support leaq or mult (or shifts, for that matter), so you'll need to access the array using pointer arithmetic - replace any array accesses (e.g., arr[i]) with pointer dereferencing and arithmetic like we did back in assignment 4 ! - Hint: also write out a "register plan" indicating which registers will be used to hold the C variables! - Your sort procedure should call your swap procedure (using a call instruction) to perform the necessary swaps. - Hint: use pushq/popq to backup/restore any registers used in sort that will also be used in swap. - (10) Implement a main procedure to call your sort procedure (using a call instruction), passing the input array and array length as arguments. I recommend using the "Y86-64 simulator" (linked on the course Links page) as a programming environment. Use the Y86-64 examples from class and the textbook as a guide. Hint: Verify that your sorting algorithm is functioning correctly by watching the Memory panel in the simulator as you step through your code (the simulator doesn't have any sort of "print" statement). Hint: Y86-64 doesn't have cmpq or testq, either; subq will do the trick, but be careful with the side effects

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!