473,657 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(resul t[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 2700
On May 14, 3:18*am, jty0...@naver.c om 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(resul t[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
2579
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 (????????) Can someone point me to an open source solution? I don't want to have to implement a "pretty printing" AST visitor myself.
3
12904
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 preserve formatting (white space and line feeds). However, this is not true when doing the same with the <code> tag listing (it will all be pasted on one line with multiple successive spaces treated as a single space) despite the fact that...
4
1606
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 code (the unmanaged code declarations are just the same - but unmanaged) Public Class Win32Call <StructLayout(LayoutKind.Sequential)> Class MYSTRUC Public counter1 As Int6 Public counter2 As Int6 End Clas
37
5949
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 in a separate file from the HTML. Apart from the obvious advantage if you have a separate designer and programmer, are there any other advantages to code behind? Most of the stuff I've seen so far uses code inside, but that's probably
3
1504
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 derived code. Am I stuck with this situation or is there a way around it? Below is some sample code. ============================== Private Sub LoadDataInForm() '= Form_Load Call FillDataSet() Call CreateBindings() Call...
14
3623
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 readibility on browsers w/o css-support. For important notes, warnings etc I use the <pre> tag, which shows in a neat bordered box when viewed with css, and depending on its class a clarifying background-image is shown. I would like the...
3
3093
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 virtual hosting is the right way to deal with this issue. Is it possible to customise the 503 page, so that, for any resource not found issue, tomcat displays the customised page. I am trying to set the page in tomcat directory itself. I have gone...
1
1892
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 a page does specify a font-family for TT, CODE, PRE, etc., then Mozilla/Firefox displays such text no longer in my own preferred monospaced typeface but in my preferred proportional typeface. Only when I write <code><code class=...with double...
5
1988
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 wrong with the code below? I have put a hyperlink on the aspx page. And I add the attributes of the hyperlink in my code-behind. I set the attributes in code behind because I need the AddressGuid ID value. I concattenate the value and make an URL...
0
8407
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.