Question: Please comment the MIPS code to help me understand. Here is what the code accomplishes. Here is the code, partially commented. .data Matrix: .word 41,45,5,

Please comment the MIPS code to help me understand.

Here is what the code accomplishes.

Please comment the MIPS code to help me understand. Here is what

Here is the code, partially commented.

.data

Matrix: .word 41,45,5, 34,8, 15,16,23,44,48,12,32,18,47,22,8,22

.word 46,40,42,33,13,38,27,6, 29,25,18,40,47,22,26,14,3

.word 7, 48,35,9, 43,38,9, 49,28,25,42,5, 44,10,5, 38,14

.word 46,33,16,6, 13,20,31,1, 8, 17,1, 47,28,46,14,28,7

.word 32,2, 48,25,41,29,14,39,43,46,3, 39,32,49,41,28,46

.word 5, 43,2, 48,13,4, 33,41,32,19,9, 25,30,22,2, 9, 40

.word 14,47,22,18,47,3, 35,44,18,6, 33,22,11,6, 47,50,4

.word 28,34,20,30,18,27,38,5, 26,40,37,23,16,13,37,8,7

.word 48,38,39,12,10,39,23,20,21,20,33,16,24,21,25,3,46

.word 49,38,40,38,13,47,5, 13,4, 13,23,26,12,30,29,29, 3

.word 8, 20,10,13,31,7, 12,41,12,21,28,26,43,14,35,10,19

.word 49,33,25,26,24,29,46,22,7, 5, 15,41,10,31,19,41,27

.word 48,9, 23,35,18,24,8, 46,10,7, 38,40,12,36,12,22,16

.word 25,36,33,45,42,1, 42,10,12,48,10,33,9, 12,6,15, 16

.word 41,2, 36,48,30,17,27,14,21,48,35,19,12,6, 27,12,25

.word 8, 14,38,28,28,9, 50,8, 3, 29,10,41,22,15,12,6, 33

.word 22,3, 14,7, 46,40,4, 7, 46,3, 19,27,16,16,25,33,41

.text

.globl __start # main program starts in the next line

__start: addi $s0,$zero,0 # outer loop counter

addi $s1,$zero,0 # inner loop counter

la $t0,Matrix #load the matrix address

addi $t6,$zero,17 # number of columns

addi $t7,$zero,17 # number of rows

addi $s6,$zero,0

sll $t1,$t6,2

ext_loop: addi $s1,$s0,0 # reset the inner loop counter

inn_loop: mult $s0,$t1

mflo $t2 # calculate the low byte offset

sll $t3,$s1,2

add $t4,$t0,$t2 # add row offset

add $s2,$t4,$t3 # add column offset

lw $s3,0($s2) # load this element

mult $s1,$t1 # Repeat the offset calcluation for mirror element

mflo $t2

sll $t3,$s0,2

add $t4,$t0,$t2

add $s4,$t4,$t3

lw $s5,0($s4)

beq $s3,$s5,jump_equal

addi $s7,$zero,1 # write ones if different

sw $s7,0($s2)

sw $s7,0($s4)

add $s6,$s6,1 # increment the counter

j jump_unequal

jump_equal: addi $s7,$zero,0

sw $s7,0($s2)

sw $s7,0($s4)

jump_unequal:

addi $s1,$s1,1 # increment the inner loop

blt $s1,$t7,inn_loop # next inner loop

addi $s0,$s0,1 # increment the outer loop

blt $s0,$t6,ext_loop # next outer loop

.end

Background A square matrix A is symmetric if where AT is the transpose of the matrix A. That is, a for all values of indices i and j (where aij represents entries in A). For example, matrix A below is symmetric but B is not. 1 17 23 B-5 2 7 A- 5 2 7 Project Objective Our objective in this project is to check if a given Matrix is symmetric or not. We perform this with the following two steps. . Given a square Matrix, we first compare if aj aji for all entries. If they are equal we write "O" for those entries. If not we write "1". So if all the elements of a Matrix are "O" then it is a symmetric matrix. Note that the diagonal would always end up as "O". We write back to the same matrix location. E.g.: For the above Matrices A and B the final result would be A- 0 0 0 B- 1 0 0 We also aim at measuring the asymmetry. So we will be counting the number of entries in a matrix which are not equal to its mirror entry. Basically define a counter and increment the counter by 1 if aj # aji. For the above Matrix B, the value of counter would 2 as two elements are different

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!