0

How to verify if a matrix is symetric in mips ?

.data
string1: .asciiz "dati n \n"
string2: .asciiz "dati elem matrice \n"
n: .word 0
elem: .space 1024
.text

main:

li $v0,4
la $a0,string1
syscall

li $v0,5
syscall
sw $v0,n
lw $t0,n
mulo $t0,$t0,$t0
la $t1,elem
li $v0,4
la $a0,string2
syscall

read_matrix:
beq $t0,$0,end_citire
li $v0,5
syscall
sw $v0,0($t1)
addi $t0,-1
addi $t1,4
j read_matrix
end_citire:
li $v0,10
syscall

there is only the read of matrix, but i dont find a formula to acces the elements,please help

1 Answers1

0

The matrix is stored in memory beginning at address elem. To access the matrix, first load the address into a register (la $t1, elem), then calculate the offset the beginning of the matrix and use lw.

Zack
  • 6,232
  • 8
  • 38
  • 68