I need this translated in MIPS can anyone help me out?

#include <stdio.h>
int n;
int row[8], s = 0;
bool safe(int x, int y)
{
        int i;
        for (i = 1; i <= y; i++)
                if (row[y - i] == x || row[y - i] == x - i || row[y - i] == x + i) return false;
		
        return true;
		
}
void putboard()
{
		 
        printf("\nSolution #%d:\n---------------------------------\n", ++s);
        int x,y;
        for (y = 0; y < 8; printf("|\n---------------------------------\n"), y++)
                for (x = 0; x < 8; printf(x++ == row[y] ? "| Q " : "|   "));
	
}
int main(int y)
{
	
        int x;
        for (x = 0; x < 8; x++)
                if (safe(row[y - 1] = x, y - 1))
                        if (y < 8) main(y + 1);
                        else putboard();
	
      return 0;
}

This is my main prob not sure how to turn this into MIPS

if (row[y - i] == x || row[y - i] == x - i || row[y - i] == x + i) return false;

Break it down into its constituent parts:

int yi = y - i;
  int val = row[ yi ];

  if (val == x) goto return_false_part;
  if (val == x - i) goto return_false_part;
  if (val == x + i) goto return_false_part;

Stick that in the loop, and add return false and return true parts, and you should be able to translate it easily.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.