Xender1
October 6th, 2009, 04:49 AM
So I am trying to just get a feel for MIPS and playing around with some stuff. I have quite a bit of code done so far but I am really struggling with subroutines and argument registers.
Pretty much I have hard coded two arrays:
mat_a: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
mat_b: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
In the main function I set up $a0 as mat_a and $a1 as mat_b. From the main function I have a sub routine that goes to a label called matrix_add. This is where I am very confused because I do not know how to go about adding up each element in these arrays. I think that I have to set up a temp register and have it equal to each part like:
lw $t0,0($a0)
lw $t1,0($a1)
But the problem is I have another subroutine called from this routine which does the addition, so that is where I dont understand how to save only $a0 as the first part then go back and then get the second part.
Pretty much I have hard coded two arrays:
mat_a: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
mat_b: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
In the main function I set up $a0 as mat_a and $a1 as mat_b. From the main function I have a sub routine that goes to a label called matrix_add. This is where I am very confused because I do not know how to go about adding up each element in these arrays. I think that I have to set up a temp register and have it equal to each part like:
lw $t0,0($a0)
lw $t1,0($a1)
But the problem is I have another subroutine called from this routine which does the addition, so that is where I dont understand how to save only $a0 as the first part then go back and then get the second part.