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 Lab 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 nopie NO Position Independent Executable
DO NOT USE ANY TOOLS IE 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 NUMELEMENTS,
data
myArray: quad
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, NUMELEMENTS ;
Write a subroutine called mySort that has two parameters, the address of an array and the number of elements in the array. The subroutine: establishes the stack frame, pushes registers used by the subroutine, uses the parameters, sorts the elements in the array parameter using the mySwap subroutine, and 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: establishes the stack frame, pushes registers used by the subroutine, uses the parameters, swaps the values pointed to by the two parameters, and 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
points Comments and style dont forget file and function comment headers.
Code correctness
o points Correct call of the mySort subroutine including the assembly for
mySort myArray, NUMELEMENTS ;
o mySort
points Stack frame established in mySort
points Registers used in mySort subroutine saved on the stack with code in the mySort subroutine
points Parameters in the mySort subroutine retrieved from the stack
points Correct call to mySwap subroutine to swap array elements including the assembly for
mySwap &arrayElement &arrayElement;
where arrayElementn are the elements to swap.
points Registers used in mySort subroutine restored from the stack with code in the mySort subroutine
points Stack frame restored with code in the mySort subroutine before returning
o mySwap
points Stack frame established in mySwap
points Registers used in mySwap subroutine saved on the stack with code in the mySwap subroutine
points Parameters in the mySwap subroutine retrieved from the stack
points Registers used in mySwap subroutine restored from the stack with code in the mySwap subroutine
points Stack frame restored with code in the mySwap subroutine before returning
o points Other miscellaneous
Program correctness
o points Array elements are sorted
What to turn in see Online Course Calendar for due dates
Turnin document: Fill out the turnin 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
