Question: Please comment every line of code I need to write a mips assembly program . In this program, we will be using mars 4.5. The
Please comment every line of code
I need to write a mips assembly program. In this program, we will be using mars 4.5. The objective of this program is to generate a list of 10 random integers and sort it in ascending order by bubblesort. Additional information, start in the data memory first starting at location highlighted(indicated) by the label LIST. Therefore, first display the unsorted list of 10 random integers separted by commas and then the list of sorted integers in ascending order.
For example, the program should display like this
Unsorted: 5, 4, 6,7,3,2,8,1,9,10 Sorted: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
I managed to create 10 random int but I need someone to implement the bubblesort.
Here is my code: Please modify or feel free to use your own to implement the bubblesort.
NOTE: Don't just copy and paste my code because some chegg "expert" decided to just copy and paste my code and didn't even do anything to modify the code to work...
.text # generate 10 random integers in the range 100 from the # seeded generator (whose id is 1) li $t2, 11 # max number of iterations + 1 li $t3, 0 # current iteration number
LOOP: li $a0, 1 # as said, this id is the same as random generator id li $a1, 100 # upper bound of the range li $v0, 42 # random int range syscall
# $a0 now holds the random number
# loop terminating condition addi $t3, $t3, 1 # increment the number of iterations beq $t3, $t2, EXIT # branch to EXIT if iterations is 10
# $a0 still has the random number # print it li $v0, 1 # print integer syscall syscall
# print a space la $a0, spacestr # load the address of the string (pseudo-op) li $v0, 4 # print string syscall syscall li $v0, 30 # get time in milliseconds (as a 64-bit value) syscall
move $t0, $a0 # save the lower 32-bits of time
# seed the random generator (just once) li $a0, 1 # random generator id (will be used later) move $a1, $t0 # seed from time li $v0, 40 # seed random number generator syscall syscall # Do another iteration j LOOP
# Tell MARS to exit the program EXIT: ##li $v0, 10 # exit syscall syscall
.data # Create a string to separate the 100 numbers with a space spacestr: .asciiz " "
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
