ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
void multiply_matrices(int [3][3], int [3][3], int [3][3]);
void show_resulting_matrix(int a[][3]);
int main(void)
{
int a[3][3] = { {5, 9, -7}, {6, 1, 3}, {-5, 2, 5} };
int b[3][3] = { {2, 9, 0}, {7, 0, 2}, {1, 1, 6} };
int c[3][3];
multiply_matrices(a, b, c);
show_resulting_matrix(c);
}
void multiply_matrices(int a[3][3], int b[3][3], int c[3][3])
{
int i=0;
while(i < 3)
{
int j=0;
while(j < 3)
{
int k=0;
int temp = 0;
while(k < 3)
{
temp = a[i][k] * b[k][j] + temp;
c[i][j] = temp;
k++;
}
j++;
}
i++;
}
}
void show_resulting_matrix(int a[3][3])
{
int i=0;
while (i < 3)
{
int j=0;
while (j < 3)
{
printf("%d\t", a[i][j]);
j++;
}
printf("\n");
i++;
}
}// end of matrix.c
I need to translate this into MIPS instructions.
But I dont' know how to start. Can anyone show me how to use multiple array(i.e. a[3][3]) and index to call the stored values?
Thank you.
Last edited by kponenation; 10-02-2005 at 04:18 PM.
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379
Rep:
Sorry but i'm not getting you. What do you mean by MIPS? If you mean MIPS baed Linux ( mips-based platforms) then you need LinuxMIPS kernel and development stuff. See url www.linux-mips.org/
yeah I tried that already. Since i don't have a MIPS machine, I get something similar to MASM, which is different from MIPS.
Was your compiler a native compiler, or a MIPS cross compiler? I have used GCC on a Sun Sparc running Solaris that I built to be a MIPS cross-compiler. It built perfectly acceptable MIPS object modules and executables. I also used the -S option a few times during the testing of the cross-compiler to insure that it generated the same of sort MIPS assembler that a native MIPS GCC compiler generated.
A native compiler. Where do I download a MIPS cross compiler?
I don't know where to get a prebuilt cross compiler. I built the one that I used using normal gcc sources. It took a little tinkering to get it to compile properly on the Solaris system, but once that was taken care of, it worked fine.
I would presume that the latest gcc compiler would work. If it dosen't, then give the folks maintaining it an e-mail asking for help. They are very supportive.
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379
Rep:
According to gnu/gcc site "Cross-compilers for the MIPS as target using the MIPS assembler currently do not work, because the auxiliary programs mips-tdump.c and mips-tfile.c can't be compiled on anything but a MIPS. It does work to cross compile for a MIPS if you use the GNU assembler and linker"
I'm also hacking DLINK based router and got cross gcc tar ball from http://mcmcc.bat.ru/dlinkt/ to put my own stuff (like ssh, ftp client and other stuff) inside it .
Although the aside on generating mips assembly using a cross compiler is interesting, this sounds like a homework question. I recommend reading a book on mips assembly. After that it shouldn't be too hard :-)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.