Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSC 225

Arrays, Structs, and Recursive Functions

Objectives:

You may work with a partner on this assignment.

Understand the machine level implementation of a recursive function calls. Learn how to use arrays in C and assembly.

Learn how to use structs in C and assembly.

Expanded Goals

Learn how to implement linked lists in C and assembly Get a preview of memory management in C.

Resources:

“Assembly Programming Style Guidelines” posted on the course portal. “Simplified-Procedure-Calling-Convention” posted on the course portal.

Chapter 8- 10, “Introduction to RISC-V Programming

Starter files in ~jplanck/demo/225/Assignments/arraysort/

High-Level Description:

This program will mix C programming and assembly.  The program is an implementation of an Selection sort using both an array of integers and an array of structs. Asking you to implement n selection sort in C is pointless since there are so many solutions already available on the internet.  I provide the C code for the entire program, and the assembly code for main.  I will not discuss how the sort works, this topic is discussed in the prerequisites and you should be able to read code. You will write the recursive sorting functions.

There are two required parts and an extra credit part to this assignment.  The first part will be implementing a recursive sort for an array.  The second part is expanding the sort so that it works for an array of structs. The extra credit uses a linked list.

Requirements:

Your functions must match the logic of the C code.

Do not Optimizeor refactorthe code.

Do not add subroutines, loops, or comparisons that is not in the C code.

Do not remove subroutines, loops, or comparisons that is in the C code.

All functions must fully comply with Assembly Programming Style Guidelines” posted on the course portal.

All functions must fully comply with the

“Simplified-Procedure-Calling-Convention” posted on the course portal.

Do not edit completed assembly files containing main. I will not look at it or use it when I execute (i.e. grade) your code.

I will use a different main program for grading than the one I gave you.    That should not make a difference ifyou properly followed the Procedure Calling Convention.

I will not share my main.asm

Details:

Part 1: Integer Selection Sort

A complete program in C is provided.

Compile the source code and execute on the unix servers attempting to translate the code

Compile and execute the C program so you understand what the behavior looks like. Examine the program so you understand the code.

Translate the selectionsort and swap functions in ArraySort.c to assembly using the provided  arraysort.og as a starting point.

The provided arraysort.og contains the c code as comments, labels, and other helpful comments to help you structure your code.

Rename arraysort.og to arraysort.asm

Do not modify arraymain.asm

You can modify arraymain.asm for debug and testing purposes.          Your code in arraysort.asm must not depend on any edits you made to arraymain.asm for proper operation.

Your code must be in arraysort.asm.

Part 2: Struct Array Selection Sort

Part 2 requires that you expand your example to sort an array of structs based on the value of one of the struct elements. A complete program in C is provided in structSort.c.

Compile and execute the C program so you understand what the behavior looks like. Examine the program so you understand the code.

Translate the selectionsort, swap and printarray functions in structsort.c to assembly using structsort.og as a starting point.

The provided structsort.og contains the c code as comments, labels, and other helpful comments to help you structure your code.

Rename structsort.og to structsort.asm

Do not modify structmain.asm

You can modify structmain.asm for debug and testing purposes.          Your code in structsort.asm must not depend on any edits you made to structmain.asm for proper operation.

Your code must be in structsort.asm.

Part 3: Linked List Selection Sort -Extra Credit

Part 3 requires that you sort a linked list of structs based on the value of one of the struct elements. A complete program in C is provided in listSort.c.

Compile and execute the C program so you understand what the behavior looks like. Examine the program so you understand the code.

Translate the selectionsort function from listSort.c to assembly using listsort.og as a starting point.

The provided listsort.og contains the c code as comments, labels, and other helpful comments to help you structure your code.

Rename listsort.og to listsort.asm

Translate any missing helper functions.

Do not modify listmain.asm

You can modify listmain.asm for debug and testing purposes.

Your code in listsort.asm must not depend on any edits you made to listmain.asm for proper operation.

Your code must be in listsort.asm.

Assignment submission

Refer to the course portal for assignment submission instructions.