Question: I have attached a MIPS Assembly program below that takes a 13x13 diamond containing 85 disks of varying diameter and hue. A rearrangement must be
I have attached a MIPS Assembly program below that takes a 13x13 diamond containing 85 disks of varying diameter and hue. A rearrangement must be derived where each row includes monotonically increasing hue (color hue) from left to right and each column includes monotonically increasing diameter from top to bottom
Please optimize (correct if any mistakes and improve the code) the MIPS Assembly language code attached below.


.data Array: # allocate static space for diamond .alloc 169 text # set memory base $01,$00, Array # create sort diamond and update memory addi SortDiamond: swi 521 addi $06, $00,6 addi . $07, $00, 12 addi l $12, $00, 0 addi $21,$00,0 addi $22, $00, 0 # constant 6 # constant 12 # counter inner # counter in bubble # bs counter # find the address first element to sort (row) addi $20, 01, 72 $26, $20, 0 $10, $00,1 $11,$00,2 $23, $00, 2 bigloop: addi addi addi addi # starts from 1 # sort times lw $17, 0 ($26) 5 bsroOW: .6 1w $18, 4 (S26) andi $27, $17, 0x003F andi s28, 18, 0x003F slt $19, $28, $27 beq $19, 500, go sw $17, 4 (26) sw $18, 0 (926) addi $22, $00, 1 # this is the indicator of bubble sort 32 34 5 go: 36 37 38 addi 26, $26, 4 addi $21, $21, 1 bne $21, $23, bsrow addi 12, 12, 1 9 loopi: 40 41 42 addi26, 20, 0 addi 23, $23, -1 addi$21, $00, 0 beq $22, $00, loopj bne $12, 11, bsrow # jump if it doesn't do bubble sort in one loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
