# Multiplication 1D Array in MİPS

Posted 28 November 2018 - 12:31 PM

Im newbie in mips. I want to multiplicate two 1D dimensional arrays. The way which I follow is wrong ? Im confused.

```Void  mm(Double x[], double y[]){
int i , j ;
for(i=0; i!=32 ; i++)
for(j=0; j!=32 ; j++)
x[i]=x[i]*y[j];
}
```

Addresses of x,y in \$a0,\$a1 and i,j in \$s0 , \$s1 by the way the matrix 1x32

li \$t1 ,32 # \$t1 =32 (end of the loop)
li \$s0, 0 # i = 0; initialize 1st for loop
L1: li \$s1, 0 # j = 0; restart 2nd for loop
sll \$t2, \$s0, 5 # \$t2 = i * 32 (size of row of x)
mulu \$t2, \$t2, \$s1 # \$t2 = i * size(row) * j
sll \$t2, \$t2, 3 # \$t2 = byte offset of [i]
l.d \$f4, 0(\$t2) # \$f4 = 8 bytes of x[i]
l.d \$f18, 0(\$t0) # \$f18 = 8 bytes of y[j]
mul.d \$f18 , \$f4 , \$f18 # \$f18 = x[i] * y[j]
addiu \$s0, \$s0, 1 # \$i = i + 1
bne \$s0, \$t1, L1 # if (i != 32) go to L1

this is my solution but what is wrong with that ?

Is This A Good Question/Topic? 0

## Replies To: Multiplication 1D Array in MİPS

### #2 #define Reputation: 1860
• Posts: 6,698
• Joined: 19-February 09

## Re: Multiplication 1D Array in MİPS

Posted 28 November 2018 - 02:02 PM

Hi, welcome.

Here How to Multiply Matrices it says.

Quote

When we do multiplication:

The number of columns of the 1st matrix must equal the number of rows of the 2nd matrix.
And the result will have the same number of rows as the 1st matrix, and the same number of columns as the 2nd matrix.

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }