473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

c code -> mips code



if you have mips cross compiler, please convert this c code to mips
code.

i'm try to install mips compiler 3 days, but some error fail to that.

so if you have something cross compiler c code -mips code , please
convert this to me. thx!





#include<stdio.h>
int x[8]={-1,5,2,8,7,1,9,3};
int y[8]={-1,5,3,4,2,6,6,2};

int distance(int a,int b){

return ( (x[b]-x[a] )*( x[b]-x[a] ) + ( y[b]-y[a] )*( y[b]-y[a] ) );
}

int main()
{

int weigh[8][8]={0,};

int result[8]={-1,7,0,0,0,0,0,1};
int total [8]={0,};
int i,j;

int min;
int minindex;
/*----------------------------------------------------*/
i=1;
for1: if( i 7 ) goto done;

j=1;
for2: if( j 7 ) goto done2;

weigh[i][j] = distance(i,j);
if(i==j) weigh[i][j]=999;
if(j==1 || j==7 ) weigh[i][j]=999;
printf("%d ",weigh[i][j]);
j++;

goto for2;

done2:
printf("\n\n");

i++;
goto for1;
done:
/*-----------------------------------------------------*/
i=1;
for3: if(i>5) goto done3;

min=999;
j=1;

for4: if(j>6) goto done4;

if( min weigh[ result[i] ][j] )
{

min=weigh[ result[i] ][j];
minindex=j;
}
j++;
goto for4;

done4:
result[i+1]=minindex;
total[i]=weigh[ result[i]][result[i+1]];
weigh[1][minindex]=999;
weigh[2][minindex]=999;
weigh[3][minindex]=999;
weigh[4][minindex]=999;
weigh[5][minindex]=999;
weigh[6][minindex]=999;
weigh[7][minindex]=999;

i++;
goto for3;

done3:

/*-----------------------------------------------------------*/
total[6]=distance(result[6],result[7]);
printf("%d %d %d %d %d %d %d
\n",result[7],result[6],result[5],result[4],result[3],result[2],result[1]);
printf("%d %d %d %d %d %d
%d",total[7],total[6],total[5],total[4],total[3],total[2],total[1]);
return 0;
}
Jun 27 '08 #1
1 2687
On May 14, 3:18*am, jty0...@naver.com wrote:
if you have mips cross compiler, please convert this c code to mips
code.

i'm try to install mips compiler 3 days, but some error fail to that.

so if you have something cross compiler *c code -mips code , please
convert this to me. thx!

#include<stdio.h>

int x[8]={-1,5,2,8,7,1,9,3};
int y[8]={-1,5,3,4,2,6,6,2};

int distance(int a,int b){

* * * * * * * * return ( (x[b]-x[a] )*( x[b]-x[a] ) + ( y[b]-y[a] )*( y[b]-y[a] ) );
* * * * }

int main()
{

* * * * int weigh[8][8]={0,};

* * * * int result[8]={-1,7,0,0,0,0,0,1};
* * * * int total [8]={0,};
* * * * int i,j;

* * * * int min;
* * * * int minindex;
/*----------------------------------------------------*/
* * * * i=1;
* * * * for1: * if( i 7 ) goto done;

* * * * * * * * j=1;
* * * * * * * * for2: * if( j 7 ) goto done2;

* * * * * * * * * * * * weigh[i][j] = distance(i,j);
* * * * * * * * * * * * if(i==j) weigh[i][j]=999;
* * * * * * * * * * * * if(j==1 || j==7 ) weigh[i][j]=999;
* * * * * * * * * * * * printf("%d *",weigh[i][j]);
* * * * * * * * * * * * j++;

* * * * * * * * * * * * goto for2;

* * * * * * * * done2:
* * * * printf("\n\n");

* * * * * * * * i++;
* * * * * * * * goto for1;

* * * * done:
/*-----------------------------------------------------*/
* * * * * * * * i=1;
* * * * for3: if(i>5) goto done3;

* * * * * * * * * min=999;
* * * * * * * * * j=1;

* * * * for4: if(j>6) goto done4;

* * * * * * * * * * * * * * * * if( min weigh[ result[i] ][j] )
* * * * * * * * * * * * * * * * {

* * * * * * * * * * * * * * * * * * * * min=weigh[ result[i] ][j];
* * * * * * * * * * * * * * * * * * * * minindex=j;
* * * * * * * * * * * * * * * * }
* * * * * * * * * * * * * * * * j++;
* * * * * * * * * * * * * * * * goto for4;

* * * * * * * * * * * * done4:

* * * * * * * * * * * * result[i+1]=minindex;
* * * * * * * * * * * * *total[i]=weigh[ result[i]][result[i+1]];
* * * * * * * * * * * * weigh[1][minindex]=999;
* * * * * * * * * * * * weigh[2][minindex]=999;
* * * * * * * * * * * * weigh[3][minindex]=999;
* * * * * * * * * * * * weigh[4][minindex]=999;
* * * * * * * * * * * * weigh[5][minindex]=999;
* * * * * * * * * * * * weigh[6][minindex]=999;
* * * * * * * * * * * * weigh[7][minindex]=999;

* * * * * * * * * * * * i++;
* * * * * * * * goto for3;

* * * * done3:

/*-----------------------------------------------------------*/
* * * * total[6]=distance(result[6],result[7]);

* * * * printf("%d %d %d %d %d %d %d
\n",result[7],result[6],result[5],result[4],result[3],result[2],result[1]);
* * * * printf("%d %d %d %d %d %d
%d",total[7],total[6],total[5],total[4],total[3],total[2],total[1]);

* * * * return 0;

}- Hide quoted text -

- Show quoted text -
Mips is a hardware architecture. The operating system is not
specified. Could be IRIX. Could be Linux. Could be NetBSD. Could
be OpenBSD. Could be Ultrix. Could be Pyramid. Could be Windows/NT
or RISC/OS or UNIX System V or SINIX. MIPS hardware is also used in
some Video game systems.

However, today is your happy day. This program just outputs a fixed
list of items, no matter what platform you compile it for. Output is
at the bottom.

#include <stdio.h>
static const int x[8] = {-1, 5, 2, 8, 7, 1, 9, 3};
static const int y[8] = {-1, 5, 3, 4, 2, 6, 6, 2};

int distance(int a, int b)
{
return ((x[b] - x[a]) * (x[b] - x[a]) + (y[b] - y[a]) * (y[b] -
y[a]));
}
int main()
{
int weigh[8][8] = {0};
int result[8] = {-1, 7, 0, 0, 0, 0, 0, 1};
int total[8] = {0};
int i,
j;
int min;
int minindex = 0;
/*----------------------------------------------------*/
i = 1;
for1:
if (i 7)
goto done;
j = 1;
for2:
if (j 7)
goto done2;
weigh[i][j] = distance(i, j);
if (i == j)
weigh[i][j] = 999;
if (j == 1 || j == 7)
weigh[i][j] = 999;
printf("%d ", weigh[i][j]);
j++;
goto for2;
done2:
printf("\n\n");
i++;
goto for1;
done:
/*-----------------------------------------------------*/
i = 1;
for3:
if (i 5)
goto done3;
min = 999;
j = 1;
for4:
if (j 6)
goto done4;
if (min weigh[result[i]][j]) {
min = weigh[result[i]][j];
minindex = j;
}
j++;
goto for4;
done4:
result[i + 1] = minindex;
total[i] = weigh[result[i]][result[i + 1]];
weigh[1][minindex] = 999;
weigh[2][minindex] = 999;
weigh[3][minindex] = 999;
weigh[4][minindex] = 999;
weigh[5][minindex] = 999;
weigh[6][minindex] = 999;
weigh[7][minindex] = 999;
i++;
goto for3;
done3:
/*-----------------------------------------------------------*/
total[6] = distance(result[6], result[7]);
printf("%d %d %d %d %d %d %d \n", result[7], result[6],
result[5], result[4], result[3], result[2], result[1]);
printf("%d %d %d %d %d %d %d", total[7], total[6],
total[5], total[4], total[3], total[2], total[1]);
return 0;
}
/*
999 13 10 13 17 17 999

999 999 37 26 10 58 999

999 37 999 5 53 5 999

999 26 5 999 52 20 999

999 10 53 52 999 64 999

999 58 5 20 64 999 999

999 2 29 16 20 52 999

1 6 3 4 5 2 7
0 17 5 5 52 10 2
*/
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ricardo Santos | last post by:
Hi, I have a Python AST, which I have modified slightly (but still a valid Python AST). How do I go back to its source code representation? source code -> AST (POSSIBLE) AST -> source code ...
3
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
4
by: James L. Brown | last post by:
Hello I'm currently working on a project, that contains one .net (VB) executable and a C++ (MFC) DLL. Now, what I want to do is to call the functions in the dll out of my managed code //managed...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
3
by: dbuchanan | last post by:
Can inherited code call derived code? If so how. I have identical 'generic' code that I am repeating again and again in several derived form because I don't know how to get inherited code to call...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
3
by: Yash | last post by:
Hi all, I found that while we are updating our application, the application is not known to tomcat, untill it is completed. So tomcat sends 503 page as resource not found. I want to know is...
1
by: Andreas Prilop | last post by:
I've come along a strange behaviour (bug?) in the Mozilla/Firefox browsers. It does not happen in Internet Explorer. When I have *disabled* the option "Allow pages to choose their own fonts" and...
5
by: mesut | last post by:
Hi there, how are you colleagues? I try to set a linkaddress in code behind for a <asp:hyperlinkserver control. but I think I have some syntax problem. I don't know how to fix it. What's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.