In this lab you will compile a series of programs written in the C programming language, examine the assembly language they generate, and run it in the miniMIPS simuator. Start by entering the following program into the miniMIPS C-compiler.
int x, y;
int gcd() {
while (x != y)
if (x < y)
y = y - x;
else
x = x - y;
}
int main() {
x = 72;
y = 120;
gcd();
return x;
}
Press [Compile], and then, if there are no syntax errors, a window will appear with the generated assembly language. Examine the assembly code and contrast it with the code you developed in last week's lab. Next, cut and paste this code into the miniMIPS simulator. Set a breakpoint at the "halt" label (insert a * in front of the line "halt:"), and run it. Examine the results in $2.
Getting used to mistakes
Try modifying the given code in the compiler window (you will need to go back a page in your browser window with the generated assembly code). You should also insert a syntax error (i.e. remove a ";") to see how the miniMIPS C-compiler responds.