Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org MIPS question...
 Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Notices

 10-02-2005, 04:16 PM #1 kponenation Member   Registered: Jul 2004 Location: New Orleans, Louisiana Distribution: Slackware 10.1 Posts: 142 Rep: MIPS question... 3x3 matrix multiplier I wrote in C Code: ```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.
 10-03-2005, 09:14 AM #2 nixcraft Member   Registered: Nov 2004 Location: BIOS 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/
 10-03-2005, 09:50 AM #3 kponenation Member   Registered: Jul 2004 Location: New Orleans, Louisiana Distribution: Slackware 10.1 Posts: 142 Original Poster Rep: I mean MIPS assembly language. Thanks.
 10-03-2005, 10:53 AM #4 schneidz LQ Guru   Registered: May 2005 Location: boston, usa Distribution: fc-15/ fc-20-live-usb/ aix Posts: 5,112 Rep: yay, my 100th post.
 10-03-2005, 10:56 AM #5 schneidz LQ Guru   Registered: May 2005 Location: boston, usa Distribution: fc-15/ fc-20-live-usb/ aix Posts: 5,112 Rep: i haven't dealt with mips before. i vaguely remember 65c02/ moto68k (from my college days). what i would do is run cc/ gcc using the -S option. it should give you an assembly file for the platform you compiled on. hth
 10-03-2005, 11:06 AM #6 kponenation Member   Registered: Jul 2004 Location: New Orleans, Louisiana Distribution: Slackware 10.1 Posts: 142 Original Poster Rep: yeah I tried that already. Since i don't have a MIPS machine, I get something similar to MASM, which is different from MIPS.
10-03-2005, 11:28 AM   #7
rstewart
Member

Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep:
Quote:
 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.

 10-03-2005, 11:38 AM #8 kponenation Member   Registered: Jul 2004 Location: New Orleans, Louisiana Distribution: Slackware 10.1 Posts: 142 Original Poster Rep: A native compiler. Where do I download a MIPS cross compiler? I tried to reconfigure gcc so that it will compile to MIPS, but it didn't work.
10-03-2005, 12:05 PM   #9
rstewart
Member

Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep:
Quote:
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.

 10-03-2005, 12:17 PM #10 nixcraft Member   Registered: Nov 2004 Location: BIOS 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 have downloaded it from MIPS tech web site http://www.mips.com/content/Products...e/content_html 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 . Hope this helps.
 10-04-2005, 01:21 AM #11 kees-jan Member   Registered: Sep 2004 Distribution: Debian, Ubuntu, BeatrIX, OpenWRT Posts: 273 Rep: 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 :-) Groetjes, Kees-Jan

 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 Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post kponenation Programming 1 10-01-2005 09:12 PM j.vilon Linux - Software 6 09-28-2005 08:12 PM tomcat22 Linux - General 0 10-07-2004 05:24 AM Gnute Programming 1 08-24-2004 05:33 PM fenriswolf Programming 0 10-17-2001 03:01 PM

All times are GMT -5. The time now is 11:16 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -