Descending and Ascending selection sort in in-line x64 assembly homework

Job ID: 31862047

Budget: $30 – $250 USD

Description:
You are responsible to write an assembly function to perform sorting of a list of integer key values. This function can sort either in ascending or descending order. You will use the selection sort algorithm for this function. This function should be assembly code using the ASM block on C++ file.

Program Specification:

int sorter ( long* list, long count, long opcode );

list – the starting address of the list of integers to be sorted

count – total number of integers in the list

opcode -

1. Ascending
2. Descending

Additional Information:

- You must use the XCHG instruction to swap your array element values
- The input list stored in a text file with the filename being passed by command line argument.
- The output is display on the screen.
- You will first sort the list based on command line parameter in either ascending or descending order and then print it out.
- You must add comments to each line of your ASM code inside sorter().
- To get full credit, you need to use the same block of code for ASC and DESC. If you use two separate blocks of code, then your maximum score will be <=80%.

Program Checklist:

The p2sample.cpp file has code inside the sorter function to swap the element in reverse order. Study that code carefully and you should be able to use similar logic/technique for the selection sort algorithm.

Here is the selection sort algorithm which you need to implement in assembly.

void sorter (long* list, long count, long opcode)
{
long x, y, temp;
for (x = 0; x < count - 1; x++)
for (y = x; y < count; y++)
if (list[x] > list[y])
{
temp = list[x];
list[x] = list[y];
list[y] = temp;
}
}
Related categories: x86/x64 Assembler