Question about my MIPS Program

M

Milk

Hi,
i got a program working half part and my program is suppose to do 4*4 matrix
can any one help me to check it? i dunno whic part i did wrong thx~~

Here is the program :::::
.data
arrayA: .space 1024
arrayB: .space 1024
arrayC: .space 1024
str: .asciiz " "

.text
main:
move $s1, $zero #initial j to 0
move $s2, $zero #initial i to 0
move $s3, $zero #initial k to 0
li $t4, 4
move $t0, $zero #initial array A to 0
move $t1, $zero #initial array b to 0
move $t2, $zero #initial array c to 0


L1:
mul $s4, $s1, $s2 #s4 = ixj
la $t6, arrayA($t0) #loading the array address
sw $s5, 0($t6) #a[j] = ixj
addiu $t0, $t0, 4 #move to next array location in matrix a

la $t7, arrayB($t1) #loading the array address
sw $s4, 0($t7) #b[j] = ixj
addiu $t1, $t1, 4 #move to next array location in matrix b
#-----------------------------------------------------------------------
li $v0, 1 #print int
addu $a0, $s4, $zero #print out matrix a[j]
syscall

#-------------------------------------------------------------------------

addiu $s2, $s2, 1 #s2 i add 1
bne $s2, $t4, L1 #if s2 not equal 4 go back L1
li $s2, 0 #initial i to 0
addiu $s1, $s1, 1 #s1 j add 1
bne $s1, $t4, L1
#--------------------------------------------------------------

move $s1, $zero #reset j to 0
move $s2, $zero #reset i to 0
move $s6, $zero
move $t0, $zero #reset array A to 0
move $t1, $zero #reset array b to 0
move $t6, $zero #reset t6
move $t7, $zero #reset t7

L2:
la $t8, arrayC($t2) #load an array address
sw $s6, 0($t8) #arrayC = s6

L3:
la $t3, arrayA($t0) #load value from array A to t3
lw $s8, 0($t3)
la $t9, arrayB($t1) #load value from array B to t3
lw $s7, 0($t9) #c[k] = 0
mul $t5, $s8, $s7 #a[k][j]b[j]
add $s7, $s7, $t5 #c[k]=c[k]+a[k][j]*b[j]
#-----------------------------------------------------------------------
li $v0, 1 #print int
addu $a0, $s7, $zero #print out matrix a[j]
syscall

#------
mul $t6, $s3, $t4 #t6= k*16
add $t6, $t6, $s1 #t6= k*16+j
mul $t0, $t6, 4 #move to next address in arrayA

mul $t7, $s1, $t4 #t6= j*16
add $t7, $t7, $s2 #t6= j*16+i
mul $t0, $t7, 4 #move to next address in arrayB

addi $s1, $s1, 1 #j+1
bne $s1, $t4, L3
add $s6, $s0, $zero
move $s1, $zero
addi $t8, $t8, 4 #add address of arrayC


addi $s3, $s3, 1
bne $s3, $t4, L2
move $s3, $zero #reset k to zero

addi $s2, $s2, 1
bne $s2, $t4, L2


exit:
li $v0, 10
syscall




~ Let us linux ~
 
K

Kevin Goodsell

Milk wrote:
[One of the least topical posts ever seen on this group.]

Yeah, I think we've had about enough of you.

Shall we, gentlemen?

*PLONK*

-Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,834
Latest member
BuyCannaLabsCBD

Latest Threads

Top