187k views
4 votes
3) To help you understand why the stack pointer is important, comment out the stack pointer initialization at the beginning of your program, and then try running the program on your mega128 board and also in the simulator. What behavior do you observe when the stack pointer is never initialized

1 Answer

5 votes

Answer: To help you understand why the stack pointer is important, comment out the stack pointer initialization at the beginning of your program, and then try running the program on your mega128 board and also in the simulator. What behavior do you observe when the stack pointer is never initialized?, The program does not run correctly and no longer return from function calls. This is because the stack pointer is required in order to be able to store the address of the call and return to that specific location. Without it, the program does not properly run.

Explanation: The program does not run correctly and no longer return from function calls. This is because the stack pointer is required in order to be able to store the address of the call and return to that location. Without it, the program no longer properly runs.

Some difficulties were in creating the loop to load the data from program memory. It was showing me errors about using invalid registers and with the TA's help realized that I had not initialized some of the registers I was trying to use. When this was resolved, creating the program was not too difficult.

User Isakkarlsson
by
4.7k points