程序代写代做 C algorithm assembly Part B (Sorting Students) – 100 points

Part B (Sorting Students) – 100 points

In the second skeleton file attached you will find an array of structures (or student records) stored in the memory corresponding to the C declaration:

struct student{
char *name;
int final } Class[20];

Each record has two fields – The first field is the name of a student 8 characters long (including the null character at the end), and the second field is the final exam score (positive integer less than 100).
Your task is to write a RISC-V assembly language program to sort the student records. Your program should be able to sort student records by the first letter of their name or their final exam score. You should be able to sort in ascending or descending order.
The output of your program should be the sorted array printed one record per line – with Name and Final separated by a space.

What do you have to do?
• You have to use the BUBBLE SORT algorithm. No other sorting algorithm is allowed.
• Download the skeleton file called lab1b.skel and add your code to it. Rename your file to lab1b.S where kerbos ID is the ID you use to login to your UC Davis email or MyUCDavis account.
• You are permitted to use only the environment calls for the Venus RISC-V simulator and RISC-V instructions.
• You should test your program for different values number of students, of student names and scores.
• You must print out the welcome message and data like in the sample outputs
• Comment your code explaining what the equivalent C operation would be (i.e. addi t0, x0, 6 #int j=6;)
• Comment your name and ID# at the top of the file
Skeleton Code
.data
Class:
.asciiz “Bill “
.word 87
.asciiz “Art “
.word 45
.asciiz “Peter “
.word 67
.asciiz “Miller “
.word 55
.asciiz “Wells “
.word 51
.asciiz “Rahim “
.word 90
.asciiz “Thomas “
.word 67
.asciiz “Garcia “
.word 49
.asciiz “William”
.word 77
.asciiz “Janice “
.word 55
.asciiz “Emma “
.word 82
.asciiz “Susie “
.word 69
.asciiz “Katie “
.word 59
.asciiz “Gizelle”
.word 59
.asciiz “Marie “
.word 66
.asciiz “Powell “
.word 87
.asciiz “Marie “
.word 80
.asciiz “Hannah “
.word 71
.asciiz “Kristen”
.word 60
.asciiz “Jones “
.word 50
NumOfStudents: .word 20
.text
.globl main
main:
####Your code here####

done:
####Exit using environmental calls####

Output Sample 1 (Ascending Scores)

Welcome to the Grade Sorting Program
Name Grade
Art 45
Garcia 49
Jones 50
Wells 51
Miller 55
Janice 55
Katie 59
Gizelle 59
Kristen 60
Marie 66
Thomas 67
Peter 67
Susie 69
Hannah 71
William 77
Marie 80
Emma 82
Powell 87
Bill 87
Rahim 90

Output Sample 2 (Descending Names)

Welcome to the Grade Sorting Program
Name Grade
Art 45
Bill 87
Emma 82
Gizelle 59
Garcia 49
Hannah 71
Jones 50
Janice 55
Kristen 60
Katie 59
Marie 80
Miller 55
Marie 66
Powell 87
Peter 67
Rahim 90
Susie 69
Thomas 67
William 77
Wells 51

Output Sample 3 (Descending Scores)

Welcome to the Grade Sorting Program
Name Grade
Rahim 90
Powell 87
Bill 87
Emma 82
Marie 80
William 77
Hannah 71
Susie 69
Peter 67
Thomas 67
Marie 66
Kristen 60
Katie 59
Gizelle 59
Miller 55
Janice 55
Wells 51
Jones 50
Garcia 49
Art 45

General hints
• Venus allows you to set breakpoints to pause the execution of your program by clicking the line of interest
• Venus allows you to inspect memory and the registers displayed in different formats (ASCII, hex, decimal etc) Use this to trace your sorting.
• Try writing out the code in C then try to reason out an equivalent assembly program
• When referencing data in memory think about the number of bytes that needs to be traversed from an initial address to get to some piece of data. Is the data a byte, short, word, or longer? How many bytes is each?