CDA 3100 ANSWERS AND QUESTIONS SET A+
✔Suppose $s0, $v0, and $a0 are holding 60, 0, and 35, respectively. After the program
executes till p9L2, what will be the value in $v0?
jal p9L1
j p9L2
p9L1: add $v0, $v0, $a0
blt $v0, $s0, p9L1
jr $ra
p9L2: add ljhl
•
(a) 100
(b) 70
(c) The program will never run to p9L2.
(d) None of the above. - ✔✔B
✔✔Try to avoid using registers _____ and ______ - ✔✔$s0, $s7
✔✔A stack is a data structure that is first in first out. - ✔✔No
✔✔In MIPS, accessing the stack involves two instructions. - ✔✔Yes; addi and sw
✔✔A function can save registers values on the stack but need not pay attention to the
order when restoring them. - ✔✔False
✔✔Which of the following statements about MIPS stack is true?
(a) If a function has to modify $sp, it can save $sp on the stack by a "sw $sp, 0($sp)"
instruction and restore it later by a "lw $sp, 0($sp)" instruction.
(b) A "push" operation adds a new number to the stack. "push $t0" can be implemented
as a pseudo instruction as "sw $t0, -4($sp)."
(c) Both of the above.
(d) None of the above. - ✔✔D
✔✔Which of the following statements about MIPS stack is true?
, •(a) If a function does not call another function, it does not have to save $ra on the
stack.
•(b) If $sp is modified inside the function, it must be saved on the stack.
•(c) If a function calls another function, it must save $v0 on the stack.
•(d) None of the above. - ✔✔A
✔✔-In MIPS, you implement the stack by yourself by keeping $sp always pointing to the
______element on the stack - ✔✔top
✔✔What are the pointers $fp and $gp? - ✔✔frame pointer and global pointer (MIPS
functions ppt)
✔✔Which of the following statements about the MIPS interrupt mechanism is true?
(a) $EPC is created mainly for robustness. The interrupt can actually use $ra to save
the return address.
(b) It is okay to modify $t0 inside the interrupt because the main program is not
expecting $t0 to be unmodified after the interrupt.
(c) Both of the above.
(d) None of the above. - ✔✔D
✔✔Suppose a MIPS interrupt handler modifies $at but forgets to restore it before
returning. Suppose the interrupt is invoked only once. After it is invoked, which of the
following statements is true?
(a) The main program will not run correctly.
(b) The main program will not run correctly only if the interrupt is invoked during a
function call.
(c) The main program will run correctly.
(d) None of the above. - ✔✔D
✔✔Which of the following statements about the MIPS interrupt mechanism is true?
(a) An interrupt cannot be triggered during a function call (when the processor is
executing instructions inside a function).
(b) When an interrupt is triggered, the interrupt handler code is executed at the same
time the main program code is executed.
(c) Both of the above.
(d) None of the above. - ✔✔D
✔✔Which of the following statements is true?
li.s $f0, 5.0
li.s $f1, 7.0
c.lt.s $f0, $f1
bc1t p8L1
p8L0: add.s $f0, $f0, $f1
p8L1: bc1t p8L0
p8L2:
✔Suppose $s0, $v0, and $a0 are holding 60, 0, and 35, respectively. After the program
executes till p9L2, what will be the value in $v0?
jal p9L1
j p9L2
p9L1: add $v0, $v0, $a0
blt $v0, $s0, p9L1
jr $ra
p9L2: add ljhl
•
(a) 100
(b) 70
(c) The program will never run to p9L2.
(d) None of the above. - ✔✔B
✔✔Try to avoid using registers _____ and ______ - ✔✔$s0, $s7
✔✔A stack is a data structure that is first in first out. - ✔✔No
✔✔In MIPS, accessing the stack involves two instructions. - ✔✔Yes; addi and sw
✔✔A function can save registers values on the stack but need not pay attention to the
order when restoring them. - ✔✔False
✔✔Which of the following statements about MIPS stack is true?
(a) If a function has to modify $sp, it can save $sp on the stack by a "sw $sp, 0($sp)"
instruction and restore it later by a "lw $sp, 0($sp)" instruction.
(b) A "push" operation adds a new number to the stack. "push $t0" can be implemented
as a pseudo instruction as "sw $t0, -4($sp)."
(c) Both of the above.
(d) None of the above. - ✔✔D
✔✔Which of the following statements about MIPS stack is true?
, •(a) If a function does not call another function, it does not have to save $ra on the
stack.
•(b) If $sp is modified inside the function, it must be saved on the stack.
•(c) If a function calls another function, it must save $v0 on the stack.
•(d) None of the above. - ✔✔A
✔✔-In MIPS, you implement the stack by yourself by keeping $sp always pointing to the
______element on the stack - ✔✔top
✔✔What are the pointers $fp and $gp? - ✔✔frame pointer and global pointer (MIPS
functions ppt)
✔✔Which of the following statements about the MIPS interrupt mechanism is true?
(a) $EPC is created mainly for robustness. The interrupt can actually use $ra to save
the return address.
(b) It is okay to modify $t0 inside the interrupt because the main program is not
expecting $t0 to be unmodified after the interrupt.
(c) Both of the above.
(d) None of the above. - ✔✔D
✔✔Suppose a MIPS interrupt handler modifies $at but forgets to restore it before
returning. Suppose the interrupt is invoked only once. After it is invoked, which of the
following statements is true?
(a) The main program will not run correctly.
(b) The main program will not run correctly only if the interrupt is invoked during a
function call.
(c) The main program will run correctly.
(d) None of the above. - ✔✔D
✔✔Which of the following statements about the MIPS interrupt mechanism is true?
(a) An interrupt cannot be triggered during a function call (when the processor is
executing instructions inside a function).
(b) When an interrupt is triggered, the interrupt handler code is executed at the same
time the main program code is executed.
(c) Both of the above.
(d) None of the above. - ✔✔D
✔✔Which of the following statements is true?
li.s $f0, 5.0
li.s $f1, 7.0
c.lt.s $f0, $f1
bc1t p8L1
p8L0: add.s $f0, $f0, $f1
p8L1: bc1t p8L0
p8L2: