Answered You can hire a professional tutor to get the answer.

QUESTION

Please optimize(improve and shorten) the Mips Assembly Language Code posted below to get under a: static code size of 66 instructions, dynamic...

Please optimize(improve and shorten) the Mips Assembly Language Code posted below to get under a: static code size of 66 instructions, dynamic instruction length of 13.910 instructions and a storage of a hundred words (including the eighty-five words in the diamond but excluding dedicated registers $0, $31).

Code:

.data

Array: .alloc 169 # allocate static space for diamond

.text

SortDiamond: addi $01, $00, Array # set memory base

swi 521 # create sort diamond and update memory

addi $06, $00, 6 # constant 6

addi $07, $00, 12 # constant 12

addi $12, $00, 0 # counter inner

addi $21, $00, 0 # counter in bubble

addi $22, $00, 0 # bs counter  

bigloop: addi $20, $01, 72 # find the address first element to sort(row)

addi $26, $20, 0

addi $10, $00, 1 # i starts from 1

addi $11, $00, 2 # sort times

addi $23, $00, 2

bsrow: lw $17, 0($26)

lw $18, 4($26)

andi $27, $17, 0x003F  

andi $28, $18, 0x003F

slt $19, $28, $27

beq $19, $00, go

sw $17, 4($26)

sw $18, 0($26)

addi $22, $00, 1 # this is the indicator of bubble sort

go: addi $26, $26, 4

addi $21, $21, 1

bne $21, $23, bsrow

loopi: addi $12, $12, 1

addi $26, $20, 0

addi $23, $23, -1

addi $21, $00, 0

beq $22, $00, loopj # jump if it doesn't do bubble sort in one loop

bne $12, $11, bsrow

loopj: addi $10, $10, 1 # i++

addi $22, $00, 0 # reinitialize counter

slti $19, $10, 7 # find next row

beq $19, $00, great # if i<7 next address is 48+ current

sll $11, $10, 1

addi $20, $20, 48

j less

great: sub $11, $07, $10

sll $11, $11, 1

addi $20, $20, 56

less: addi $23, $11, 0

addi $26, $20, 0

addi $12, $00, 0

bne $10, $07, bsrow

addi $20, $01, 264

addi $26, $20, 0

addi $10, $00, 1

addi $23, $00, 2

addi $11, $00, 2

bscol: lw $17, 0($26)

lw $18, 52($26)

slt $19, $18, $17

beq $19, $00, go1

sw $17, 52($26)

sw $18, 0($26)

addi $22, $00, 1

go1: addi $26, $26, 52

addi $21, $21, 1

bne $21, $23, bscol

loopi1: addi $12, $12, 1

addi $26, $20, 0

addi $23, $23, -1

addi $21, $00, 0

beq $22, $00, loopj1

bne $12, $11, bscol

loopj1: addi $10, $10, 1

addi $22, $00, 0

slti $19, $10, 7

beq $19, $00, great1

sll $11, $10, 1

addi $20, $20, -48

j less1

great1: sub $11, $07, $10

sll $11, $11, 1

addi $20, $20, 56

less1: addi $23, $11, 0

addi $26, $20, 0

addi $12, $00, 0

bne $10, $07, bscol

swi 522

bne $02, $00, bigloop

swi 523 # redisplay diamond

jr $31 # return to caller

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question