Question: Translate the following high level code into MIPS assembly. These functions require: 1) implementing doubly nested loops, 2) indexing into a two-dimensional array, and 3)
Translate the following high level code into MIPS assembly.
These functions require: 1) implementing doubly nested loops, 2) indexing into a two-dimensional array, and 3) saving/restoring registers and calling other functions. You will note that the two functions are very similar, so we recommend writing one and completely debugging it and then using that as a template for the second one.
// A board is done if all squares are singletons.
bool board_done(int board[GRID_SQUARED][GRID_SQUARED]) {
for (int i = 0 ; i < GRID_SQUARED ; ++ i) {
for (int j = 0 ; j < GRID_SQUARED ; ++ j) {
if (!singleton(board[i][j])) {
return false;
}
}
}
return true;
}
// Print the board with one value per square.
void print_board(int board[GRID_SQUARED][GRID_SQUARED]) {
for (int i = 0 ; i < GRID_SQUARED ; ++ i) {
for (int j = 0 ; j < GRID_SQUARED ; ++ j) {
int value = board[i][j];
char c = '*';
if (singleton(value)) {
c = get_singleton(value) + '1';
}
printf("%c", c);
}
printf(" ");
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
