Lab 2 problems: MIPS programming (arithmetic and control) Remember to solve these individually, working with your partner only when you get stuck, and seeking help from the TA only when you are both stuck. You may NOT use any calculators. Make sure you are on your own computer, editing your own file. This is your assignment for the week, not just for the day, so it is expected that you will not finish during this lab time. For each problem, make sure you write your answer on the line immediately after the prompt, and only on that line. For example: 0.) What is 2 + 2, in decimal? 0.answer) 4 ---MIPS Tutorial--- 1.) To display an integer to the screen, what value do you place into `$v0`? Express the answer in base 10. 1.answer) 2.) What is the value in `$a0` when `syscall` is called the sixth time within `main`? Express the answer as a hexadecimal number with 8 digits. 2.answer) 3.) To display a string to the screen, what value do you place into `$v0`? Express the answer in base 10. 3.answer) 4.) To read an integer from the user, what value do you place into `$v0`? Express the answer in base 10. 4.answer) 5.) In what register does the simulator's system call place the integer that the user entered? Give the register name (i.e. `$s0`). 5.answer) 6.) What variable is located at memory location `0x10010022?` The answer is one of: welcome, prompt, sumText, or MyArray. (For those looking at an ASCII table - you may notice that the letters are in reverse order in blocks of 4. For example, the string " This program ad" is represented as "ihT rp sargoda m". That is, every contiguous block of 4 letters is in reverse order. This is because data in MIPS is stored in what is known as "little-endian byte order", which is a topic we'll be looking at later in the class.) 6.answer) 7.) There are times (i.e. the `la` pseudoinstruction) when it is necessary to place a 32-bit constant into a register. Unfortunately, `addi` only allows a 16-bit constant. Therefore, this action requires two instructions. Let's imagine I want to place the number `0x2b7a9454` into register `$t0`. You may only use `$t0`. Write the two instructions necessary to do so, using `ori` for the second one. You may not use any pseudoinstructions. Place the instructions next to each other on the SAME LINE separated by a semicolon (;), not on different lines. Operands (the parameters to the instructions) should be separated by commas (,), and all constants should be expressed in hexadecimal with a leading `0x`. For example: addi $t0, $t0, 0x42 ; sub $s5, $s6, $s7 7.answer) ---Signed Arithmetic--- 8.) Let's assume we are on a 32-bit computer (that means ints are 32 bits). This code has a bug in it, which will lead to output that is probably not what the person intended. This question is not about what the code should be, it is about how it will act now that it is wrong. If this function is called with `countdown(5)`, what value will `i` have when the `for` loop below exits? Note that this is asking for the value of `i` when the loop exits, NOT for the value that is last printed out. void countdown(int x) { printf("Countdown: "); for(int i=x;i>=0;i++) { printf("%d, ",i); } printf(".... Blastoff!"); } Write your answer in hexadecimal. Write all digits required to specify a 32-bit number. (For the C aficionados, you may assume that the compiler treats this as normal signed arithmetic, and does a direct translation to MIPS assembly. That is, the compiler does not exploit the undefined behavior of overflow here.) 8.answer)