Question: Magic Squares Objective : Implement a non-trivial algorithm in MIPS assembly language. (.asm file) Please write in MIPS code that is compatible with MARS 4_5
Magic Squares Objective: Implement a non-trivial algorithm in MIPS assembly language. (.asm file) Please write in MIPS code that is compatible with MARS 4_5 (MIPS Assembler and Runtime Simulator).

Miscellaneous: This program must use functions and arrays. It is your decision how many functions are used and how they are defined. There is an algorithm for creating magic squares; make sure you do your research before tackling this program. I have a working source code in C++ but I need to convert it into MIPS Assembly language. (.asm file)
C++ code:
#include
using namespace std;
ofstream myfile;
// A function to generate odd sized magic squares void generateSquare(int n) { int x, y;
// Variable sized 2D array int **magicSquare = new int* [n]; for (x = 0; x
// Initializing the array to all zeros for(x = 0; x
// Initialize position for 1 int i = n/2; int j = n-1;
// One by one put all values in magic square for (int num = 1; num
j++; i--; //1st condition }
// print magic square myfile
for(i=0; i // Driver program to test above function int main() { int n; // Works only when n is odd myfile.open ("output.txt"); do { cout > n; if(n%2!=0) generateSquare(n); else if(n != 0) cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
