Flashcards on MIPS Instruction Set Architecture Fundamentals
MIPS Instruction Set Architecture Fundamentals: A Guide
Tap to flip · Swipe to navigate
MIPS Procedures and Data
14 cards
Card 1
Question: What MIPS instructions compare signed integers and which compare unsigned integers?
Answer: Signed: slt, slti. Unsigned: sltu, sltui.
Card 2
Question: Given $s0 = 0xFFFFFFFF (all ones) and $s1 = 0x00000001, what is the result of "slt $t0, $s0, $s1" and why?
Answer: $t0 = 1 because slt does a signed comparison: 0xFFFFFFFF is -1, and -1 < +1.
Card 3
Question: With the same registers ($s0 = 0xFFFFFFFF, $s1 = 0x00000001), what is the result of "sltu $t0, $s0, $s1" and why?
Answer: $t0 = 0 because sltu does an unsigned comparison: 0xFFFFFFFF = 4,294,967,295 which is > 1.
Card 4
Question: List the typical MIPS registers used for procedure calling and their conventional purposes.
Answer: $a0–$a3: arguments; $v0–$v1: result values; $t0–$t9: temporaries (can be overwritten by callee); $s0–$s7: saved (must be saved/restored by callee); $g
Card 5
Question: What are the six conceptual steps required when calling a procedure?
Answer: 1) Place parameters in registers; 2) Transfer control to procedure; 3) Acquire storage for procedure; 4) Perform procedure’s operations; 5) Place resu
Card 6
Question: How does the MIPS 'jal' instruction support procedure calls?
Answer: jal ProcedureLabel jumps to the target address and places the address of the following instruction into $ra (return address).
Card 7
Question: How does a MIPS procedure return to its caller?
Answer: By executing jr $ra, which copies $ra into the program counter.
Card 8
Question: In a leaf procedure that uses a saved register (e.g., $s0), what stack operations must it perform?
Answer: Allocate space on the stack (e.g., addi $sp, $sp, -4), sw $s0 to stack, perform body, lw $s0 from stack, addi $sp, $sp, 4, then jr $ra.
Card 9
Question: Why must non-leaf procedures save their return address and other values on the stack?
Answer: Because they call other procedures which will overwrite $ra and possibly registers; to preserve the caller’s return address, arguments, and temporarie
Card 10
Question: In the recursive factorial example, which values are saved on the stack before the recursive call and why?
Answer: The example saves $ra and $a0 on the stack so the procedure can restore the caller’s return address and original argument after the recursive call.