Hello, I am supposed to write a code in MIPS to do the following below. Basically, you enter an integer,
and it should check to see if it is a palindrome, and if not it will output the number, and keep adding the
numer backwards to it, outputting it, and stopping when it is a palindrome. It will output 10 numbers
and if the 10th number isnt a palindrome, it stops.

I'm having trouble writing this code in MIPS, i was hoping someone could offer up some ideas?
My main trouble is the loop in the Palindrome function. I believe the code I wrote for the
reverse function works well.

Below is something I quickly wrote as a guideline while writing it into MIPS.

``````int Reverse(int num)
{
int remainder = 0;
int rev = 0;

while (num != 0)
{
remainder = num % 10;
num = num/10;
rev = rev*10 + remainder;
}
return rev;
}

void Palindrome()
{
int num;

cin >> num;
Reverse(num);
cout << num;
for (int i = 0; i < 10; i++)
{
if ( num != Reverse(num))
{
num = num + Reverse(num);
cout << " " << num;
}
if (num == Reverse(num))
{
cout << " ";
}
}
}

int main()
{
cout << "Please enter an integer : " << endl;
Palindrome();

return 0;
}
``````

to make loops in assembly you need to use something similar to the goto function in c.

create a point to "goto". example:

``````move \$t0, \$zero  #set \$t0 to 0 for your counter.
pos1:
beq \$t0, 10, pos2  #terminate the loop if \$t0 equals 10