MIPs Architecture Flashcards
What is the purpose of data transfer instructions in MIPS?
To transfer data between memory and registers
Includes load and store instructions
What does the load instruction do?
Copies data from memory
In MIPS, represented as ‘lw’
What does the store instruction do?
Copies data to memory
In MIPS, represented as ‘sw’
What is the MIPS format for loading a word?
lw = load word
Used to read a 32-bit word from memory
What is the MIPS format for storing a word?
sw = store word
Used to write a 32-bit word to memory
Where do arithmetic operands occur in MIPS?
Only on registers
Memory operands are accessed differently
How is the memory address computed for reading and writing?
Base address + offset
Base from a register, offset as an integer
What is the MIPS instruction:
lw $t1, 8($t2)
mean?
Loads a word into $t1 from [$t2 + 8] in memory
Means $t1 := Memory[$t2 + 8]
What is the MIPS instruction:
sw $t1, 4($t2)
mean?
Stores a word into $t1 from [$t2 + 4] in memory
Means Memory[$t2 + 4] := $t1
How does byte addressing affect array indexing in memory?
Offset must be multiplied by the size of the data type
For example, to access A[8], offset is 4 x 8 = 32
What is the MIPS code for the C statement A[12] = h + A[8];?
lw $t0, 32($s3)
add $t0, $s2, $t0
sw $t0, 48($s3)
32 = 8x4 & 48=12x4
What is the order of operands in load word and store word instructions?
Load word has destination first, store word has destination last
Example: lw $t1, 8($t2) vs sw $t1, 4($t2)
Can arithmetic operations be performed directly on memory in MIPS?
No, arithmetic operands must be in registers
Example of invalid operation: add 48($s3), $s2, 32($s3)
What does the instruction:
add $s1, $s2, $s3
do?
$s1 = $s2 + $s3
Performs addition of values in registers
What does the instruction:
sub $s1, $s2, $s3
do?
$s1 = $s2 - $s3
Performs subtraction of values in registers
What does the instruction:
lw $s1, 100($s2)
do?
$s1 = Memory[$s2 + 100]
Loads a word from memory into $s1
What does the instruction:
sw $s1, 100($s2)
do?
Memory[$s2 + 100] = $s1
Stores the value from $s1 into memory
What are the five stages of instruction execution?
Stage 1: Instruction Fetch
Stage 2: Instruction Decode
Stage 3: ALU (Arithmetic-Logic Unit)
Stage 4: Memory Access
Stage 5: Register Write
At what stage do we increment the PC?
Stage 1: Instruction Fetch
What does the PC do?
It will point to the next instruction
PC = PC + 4
4 Bytes = 32 bits (1 instruction)
What is a word in MIPs?
32 bits or 4 bytes
What do we call the first 6 bits?
The opcode
What does the opcode determine?
The instruction type and field lengths
What inputs and outputs does ALU have?
2x32 bit inputs
1x32 bit output