Question
Observe the registers/Memory locations values after each Step Run. Record the final values. Use $t0, $t1, and $t2 to hold the numbers after the ascending
Observe the registers/Memory locations values after each Step Run. Record the final values.
Use $t0, $t1, and $t2 to hold the numbers after the ascending sort. What are the final values of $t0, $t1, and $t2?
Modify the given program to result a descending order.
.text .globl_start _start:
la $a0, array lw $a1, count # in the jal statement jal sort #jump to "sort:" j print #jump to "print:"
#start subrouten sort: sw $ra, -4($sp) #load the return address in to the stack pointer move $t6, $a1 #outter counter outter: sub $t6, $t6, 1 #sub the outter counter move $t7, $a0 #save the address for "array" into $t7 move $t5, $a1 #inner counter
inner: sub $t5, $t5, 1 #sub 1 from inner counter lw $s0,($t7) #load the two variables lw $s1,4($t7) #to be tested
ble $s0, $s1, next #if $s0 <$s1 branch sw $s1,($t7) #else switch the two sw $s0,4($t7)
next:add $t7, $t7, 4 #add 4 to the saved address for next loop bnez $t5, inner #if the inner counter is not 0 then branch bnez $t6, outter #if the outter counter is not 0 then branch
lw $ra, -4($sp) #if outter counter is 0 load top jr $ra #stack point and exit subrouten
print: #print out the final memory locations la $t7,array lw $t0,($t7) lw $t1,4($t7) lw $t2,8($t7)
.data array: .word 3,2,1 count: .word 3 ## end of file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started