Programming Forums
User Name Password Register

RSS Feed

Thread Tools Display Modes
Old Dec 10th, 2012, 2:44 AM   #1
Join Date: Dec 2012
Posts: 2
Rep Power: 0 Tioz is on a distinguished road
Recursive functions in MIPS Assembly

So I'm trying to make a program that will give me the determinant of a square matrix of a size of my choice.
To get the algorithm clear in my mind I wrote the program in C first and it works fine.
I'm half way through translating it to MIPS Assembly but I'm having problems with this recursive function:

int determinante(int dim,int matrix[dim][dim])
int i,j,k;
int D=0;
//se la matrice e' una 1x1

for(i=0;i<dim&&dim>1;++i) //scorre righe
     int mattemp[dim-1][dim-1]; //crea una matrice delle stesse dimensioni di prima (dim-1 perchè se creo una matrice d=3 se comincio a contare da i=0 ne creerebbe una 4x4)
     for(j=0;j<dim;++j) //scorre colonne
         for(k=1;k<dim&&j!=i;++k) //controllo sugli indici, controlla se il contatore è minore della dimensione della matrice e controlla che non sia sulla diagonale
         if(j<i) //se l'indice j delle colonne è minore dell'indice i delle righe mette nella matrice temporanea mattemp il valore che si torva in quella posizione
     D=D+indice(i)/*passa i alla funz indice che ritorna 1,-1*/*matrix[i][0]/*considera una matrice di un elemento*/*determinante(dim-1,mattemp)/*passa alla funz determinante la dimensione della sottomatrice e la matrice stessa e ne restituisce il determinante*/
     ; //calcola il determinante
return D;
//indice 1,-1 a seconda della posizione considerata
int indice(int ind) //funzione indice
             return 1; //controlla se la divisione tra indice colonna e indice riga è pari o dispari
     return -1;

I'm not entirely clear on how to use the stack to implement recursion. Also if you have a better algorithm to calculate the determinant please make me know.
Any help would be greatly appreciated


EDIT: just realized that perhaps without english comments the program is a bit difficult to decypher, let me know if you need the full code
Tioz is offline   Reply With Quote


« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
itoa procedure (assembly MIPS) UnSourCeR Assembly 3 Dec 26th, 2011 5:37 AM
detour in mips assembly ineya Assembly 5 May 9th, 2010 5:53 AM
Having trouble with "stacks" concept in MIPS Assembly Language (as an instruction) mothergoose729 Assembly 0 Jan 20th, 2010 2:04 AM
Recursive Functions Help mdwitt1 Assembly 0 Dec 14th, 2009 3:25 PM
MIPS assembly language cwl157 Assembly 41 Dec 4th, 2006 11:00 PM

DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:20 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC