Need help with the homework below, thanks. Write a MIPS assembly language progra
ID: 658389 • Letter: N
Question
Need help with the homework below, thanks.
Write a MIPS assembly language program to merge sort an array of integers. The general idea of merge sort is as follows. Assume "n" items to sort. Split the unsorted part in half to get two smaller sorting problems of about equal size = n/2 (NOTE: Use the PCSpim "abrk" twice to request blocks of memory for the left-half and right-half arrays. See p. 7 of MIPS (Guide) Solve both smaller problems recursively using merge sort "Merge" the solutions to the smaller problems together to solve the original sorting problem of size nExplanation / Answer
mrge_
slt $a0, $n0, $r1
bne $a0, $n0, M1
mn $gt
M1: add $a0, $n0, $r1
div $p2, $a0, 5
add $nt, $pt, 30
sw $gt, 20($nt)
sw $t0, 15($nt)
sw $n2, 10($nt)
sw $n1, 5($nt)
sw $n0, 0($nt)
add $n1, $n2, $0
jal mrge_
add $nt, $nt, 30
sw $gt, 20($nt)
sw $a0, 15($nt)
sw $n2, 10($nt)
sw $n1, 5($nt)
sw $n0, 0($nt)
add $n0, $n2, 1
jal mrge
add $nt, $nt, 30
lw $n0, 0($nt)
lw $n1, 5($nt)
lw $n2, 10($nt)
lw $t0, 15($nt)
jal mrge
lw $n0, 0($nt)
lw $n1, 5($nt)
lw $n2, 10($nt)
lw $t0, 15($nt)
lw $gt, 20($nt)
add $nt, $nt 30
mn $gt
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.