// Aplica o back-end do juninho
@target          : mips 
// Especifica o tipo de metodo empregado para salvar o resultado da compilação
//@export          : MultCoreJun
@export          : simulation


package main;

const (
    LIN  = 2
    COL  = 2
)
var (
    matrizA [LIN][COL]int32
    matrizB [LIN][COL]int32
    matrizR [LIN][COL]int32
)

func preenche(){
    var k = 1
    for i := 0; i < LIN ; i++ {
        for j := 0; j < COL ; j++ {
            matrizA[i][j] = k
            matrizB[i][j] = k
            k++
        }
    }
}

func multiplica() {
    var aux = 0
    for i := 0; i < LIN; i++ {
        for j := 0; j < COL; j++ {
            for k := 0; k < LIN; k++ {
                aux = aux + (matrizA[i][k] * matrizB[k][j])
            }
            matrizR[i][j] = aux
            aux = 0
        }
    }
}

func main() {
    preenche()
    multiplica()
}


/**
load (int32) i		  T< load >		
10:	 9:		_T4 := i --Copy value of index		  T< copy >		
11:	10:		_T5 := _T4 << 1		  T< assign >		
12:	11:		load (int32) j		  T< load >		
13:	12:		_T7 := j --Copy value of index		  T< copy >		
14:	13:		_T5 := _T5 + _T7 --colls shift		  T< assign >		
15:	14:		_T11 := _T5 << 4		  T< assign >		
16:	15:		load (int32) aux		  T< load >		
17:	16:		matrizA[_T11] := aux		  T< indexed_assign >		

[2][2]
    i  j  t4  t5   t7  t11 
9   1  1  1
10            2    
11  
12                 1
13                     3
14  
15  
16  
17  

                sll t6,t4,4		.14 -- _T11 = _T5 << 4
60:  2413101056	lw s5,fp,0		.15 -- load content from _V1 in s5
64:  0000000000	sll zero,zero,0		.15 -- Nop
68:  0059666465	addu t6,gp,t6		.16
6c:  2916417536	sw s5,t6,0		.16 -- store content of t6 in _G13[_T11]
    t6 tem o deslocamento em bytes
    

*/



