MIPS Flashcards
(14 cards)
What is the equivalent math operations for SLL & SLR?
Shifting n bits = multiplying/dividing by 2^n
What is AND usually used for?
Used for masking operation:
- Place 1s in interested positions. (Copying these bits)
What is XOR usually used for?
Toggling bits:
- Place 1s in interested positions to invert those bits.
What is NOR usually used for?
Toggling bits:
- Place 0s in interested positions to invert those bits.
What is ORI usually used for?
Loading 32-bits constants into a register:
lui the upper 16bits into register first
ori the lower 16bits into the register
What is the common technique for CONDITIONAL statements?
Invert the condition for shorter code:
E.g. if (i == j)
f = g + h;
bne i, j, exit
add f, g, h
What is the technique when dealing with WHILE loops?
while(j == k)
i = i + 1;
Rewrite as: if (j != k) goto Exit i = i + 1; goto Loop
bne j, k, Exit
addi i, i, 1
j Loop
How many instructions formats are there in MIPS?
3: R-format, I-format, J-format
How many fields are there in R-Format? What are they?
6 fields:
- opcode (6)
- rs (5)
- rt (5)
- rd (5)
- shamt (5)
- funct (6)
How many fields are there in I-Format? What are they?
4 fields:
- opcode (6)
- rs (5)
- rt (5)
- immediate (16)
What is the range of words that a conditional branch can reach?
+- 2^17
How many fields are there in J-Format? What are they?
2 fields:
- opcode (6)
- target address (26)
- ignore the first 4 bits and last 2 bits of the address (32 - 4 - 2 = 26)
What is the range of words in a jump instruction?
256MB = 2^28
What is the difference between PC-relative addressing and Pseudo-direct addressing?
Jump uses pseudo-direct addressing where the 26bit of instruction is concatenated with the upper 4 bits of PC.
Conditional Branching uses PC-relative addressing where the resulting address is the sum of PC and constant in the instruction.