Click here to Skip to main content
15,799,398 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
Can anyone please convert this C code in Mips for me? I haven't worked with Mips before and I really have no idea how to deal with it. Thanks a lot!
#include <stdio.h>
#include <stdlib.h>

static int aplica(int (*f)(int), int x)
   return (*f)(x);
static int f1(int y)
   return y+y;
static int f2(int y)
   return y*y;
static int f3(int y)
   return -y;

static int (*vf[3])(int x) = {f1, f2, f3};
static int v[3];

int main(void)
   register int i;
   for (i=0; i<3; ++i) {
   for (i=0; i<3; ++i) {
      printf("v(%d] = %d, ", i,v[i]);
   return EXIT_SUCCESS;

What I have tried:

I haven't worked in Mips before. I code in Python, C and C++. I tried to search on Google but I couldn't solve anything that's why I am asking for your help.
Updated 4-Jan-21 6:32am

This is not a code conversion service. You have to do the work yourself.

It looks like you're going to have to learn MIPS assembly language.
Share this answer
Cristina Dijmarescu 4-Jan-21 11:15am    
I was just asking for help. If you are not able to help, it doesn't mean others won't help.
Dave Kreskowiak 4-Jan-21 11:17am    
This is exactly what you asked: "Can anyone please convert this C code in Mips for me?"

That's not asking for help. That's asking for "someone do my work for me".
Dave Kreskowiak 4-Jan-21 11:22am    
You're going to have to Google for "MIPS assembly tutorials" and start teaching yourself. Avoid YouTube videos.
OriginalGriff 4-Jan-21 11:23am    
Take a 5!
As Dave has said: This is not a code conversion service: we are not here to translate code for you.
Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different frameworks, and what makes something work in one language does not always "translate" directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can’t be upgraded nicely, and that will cause you immense headaches if the original is changed. And it’ll be a nightmare to debug if it doesn’t work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.

I was just asking for help. If you are not able to help, it doesn't mean others won't help.

Why do you assume that others will want to do your work for you when you have shown no signs at all of trying for yourself? It's not exactly complicated C code, is it?
Share this answer
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900