1. In MIPS, when you load a byte from memory into a register: - What happens to
ID: 3871523 • Letter: 1
Question
1. In MIPS, when you load a byte from memory into a register:
- What happens to its value? (There are two options.)
- Why do we do this?
This class focuses mainly using MIPS
1. When we call functions, often those functions push registers on the stack and pop them off before they return. Why? (What bad things would happen if they didn't do that?)
2. For the following situations, write what kind of register you would use (a, v, t, s) and why.
x + 1 in the code check_block(x + 1, y).
i in the code for(i = 0; i < 10; i++) { ... }.
row * WIDTH in the code block_arr + row * WIDTH + col.
block_arr + row * WIDTH + col in the code return block_arr + row * WIDTH + col.
The address of my_var in the code my_var = their_var, where my_var is in memory!
Look at the following snippets of code. For each, write some C/Java-like pseudocode to show what the code does.
a.
b.
c.
d.
Explanation / Answer
1.The value in the memory remains unchanged when we load it into a register.
we do this to manipulate the value in the given memory without changing it.
2 The functions pop the registers off when they return thereby freeing the stack memory so that it can be utilized by other funtions.This prevents stack overflow which occurs when stack memory is exhausted.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.