Question: CISP 2 4 1 0 Lab 6 , Assembly Introduction This lab implements sort and swap subroutines. It includes writing two subroutines besides main and

CISP 2410 Lab 6, Assembly
Introduction
This lab implements sort and swap subroutines. It includes writing two subroutines besides main and using the stack to pass parameters by value and by reference. It requires more stack usage as the sort subroutine calls the swap subroutine multiple times. In order to get any credit for this lab, you MUST write and use a sort subroutine that sorts an array of integers by calling a swap subroutine to swap array elements as it sorts.
DONT FORGET TO SET THE gcc ASSEMBER OPTION no-pie (NO Position Independent Executable).
DO NOT USE ANY TOOLS (I.E., ASSEMBLY INSTRUCTIONS THAT WERE NOT COVERED IN CLASS). IF YOU DO, YOU WILL NOT EARN ANY CREDIT ON THE LAB ASSIGNMENT.
Detailed Information
Use the following macro and .data section:
.equ NUM_ELEMENTS, 10
.data
myArray: .quad 5,-1,4,55,-30,2,1,9,-55,10
In the .text section:
DO NOT put values in the array in main. Put them in the array as shown above in the .data section
Write a main subroutine that calls the mySort subroutine, properly containing the assembly for
mySort( myArray, NUM_ELEMENTS );
Write a subroutine called mySort that has two parameters, the address of an array and the number of elements in the array. The subroutine: 1) establishes the stack frame, 2) pushes registers used by the subroutine, 3) uses the parameters, 4) sorts the elements in the array parameter using the mySwap subroutine, and 5) pops used registers restoring the stack.
Write a subroutine called mySwap that has two parameters, the address of two values to be swapped. The subroutine: 1) establishes the stack frame, 2) pushes registers used by the subroutine, 3) uses the parameters, 4) swaps the values pointed to by the two parameters, and 5) pops used registers restoring the stack.
In order to get any credit for this lab, the code must include and use the mySort and mySwap subroutines.
Hint: the homework included a swap subroutine. Use it. It also included code to find the minimum value in an array. If you put that code in a subroutine, alter it to return the minimum index or the address of the minimum value instead of the minimum value, then a mySort that implements a selection sort can use these. The mySort that implements a selection sort can have one loop that calls finMin to find the index or address of the minimum element from the top to the bottom of the array then calls mySwap to swap this minimum element and the top element. To review, you may want to write this code in C++ first. No one can write code if they dont understand the algorithm.
Rubric
(10 points) Comments and style dont forget file and function comment headers.
Code correctness
o(4 points) Correct call of the mySort subroutine including the assembly for
mySort( myArray, NUM_ELEMENTS );
o mySort
(4 points) Stack frame established in mySort
(4 points) Registers used in mySort subroutine saved on the stack with code in the mySort subroutine
(4 points) Parameters in the mySort subroutine retrieved from the stack
(4 points) Correct call to mySwap subroutine to swap array elements including the assembly for
mySwap( &arrayElement1, &arrayElement2);
where arrayElementn are the elements to swap.
(4 points) Registers used in mySort subroutine restored from the stack with code in the mySort subroutine
(4 points) Stack frame restored with code in the mySort subroutine before returning
o mySwap
(4 points) Stack frame established in mySwap
(4 points) Registers used in mySwap subroutine saved on the stack with code in the mySwap subroutine
(4 points) Parameters in the mySwap subroutine retrieved from the stack
(4 points) Registers used in mySwap subroutine restored from the stack with code in the mySwap subroutine
(4 points) Stack frame restored with code in the mySwap subroutine before returning
o(4 points) Other miscellaneous
Program correctness
o(38 points) Array elements are sorted
What to turn in see Online Course Calendar for due dates
1. Turn-in document: Fill out the turn-in document that is part of this assignment and turn it in via the online course assignment tool which requires including a link to your onlinegdb.com assembly program.

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 Programming Questions!