MIPS Instruction ref Flashcards
The manner in which the processor executes an instruction and advances its program counters is as follows:
execute the instruction at PC
copy nPC to PC
add 4 or the branch offset to nPC
What is the difference between signed and unsigned instructions?
The only difference between signed and unsigned instructions is that signed instructions can generate an overflow exception and unsigned instructions can not.
What kind of values are arithmetic immediate values?
ALL arithmetic immediate values are sign-extended.
What is ADD
what is its encoding, operation and overflow?
Add (with overflow)
add $d, $s, $t
$d = $s + $t; advance_pc (4);
0000 00ss ssst tttt dddd d000 0010 0000
Adds two registers and stores the result in a register
What is ADDI
what is its encoding, operation and overflow?
Add immediate (with overflow)
addi $t, $s, imm
$t = $s + imm; advance_pc (4);
0010 00ss ssst tttt iiii iiii iiii iiii
Adds a register and a sign-extended immediate value and stores the result in a register
What is ADDIU
what is its encoding, operation and overflow?
Add immediate unsigned (no overflow)
addiu $t, $s, imm
$t = $s + imm; advance_pc (4);
0010 01ss ssst tttt iiii iiii iiii iiii
Adds a register and a sign-extended immediate value and stores the result in a register
What is ADDU
what is its encoding, operation and overflow?
Add unsigned (no overflow)
addu $d, $s, $t
$d = $s + $t; advance_pc (4);
0000 00ss ssst tttt dddd d000 0010 0001
Adds two registers and stores the result in a register
What is AND
what is its encoding, operation and overflow?
Bitwise and
and $d, $s, $t
$d = $s & $t; advance_pc (4);
0000 00ss ssst tttt dddd d000 0010 0100
Bitwise ands two registers and stores the result in a register
What is ANDI
what is its encoding, operation and overflow?
Bitwise and immediate
andi $t, $s, imm
$t = $s & imm; advance_pc (4);
0011 00ss ssst tttt iiii iiii iiii iiii
Bitwise ands a register and an immediate value and stores the result in a register
What is BEQ
what is its encoding, operation and overflow?
Branch on equal
beq $s, $t, offset
if $s == $t advance_pc (offset «_space;2)); else advance_pc (4);
0001 00ss ssst tttt iiii iiii iiii iiii
Branches if the two registers are equal
What is BGEZ
what is its encoding, operation and overflow?
Branch on greater than or equal to zero
bgez $s, offset
if $s >= 0 advance_pc (offset «_space;2)); else advance_pc (4);
0000 01ss sss0 0001 iiii iiii iiii iiii
Branches if the register is greater than or equal to zero
What is BGEZAL
what is its encoding, operation and overflow?
Branch on greater than or equal to zero and link
bgezal $s, offset
if $s >= 0 $31 = PC + 8 (or nPC + 4); advance_pc (offset «_space;2)); else advance_pc (4);
0000 01ss sss1 0001 iiii iiii iiii iiii
Branches if the register is greater than or equal to zero and saves the return address in $31
What is BGTZ
what is its encoding, operation and overflow?
Branch on greater than zero
bgtz $s, offset
if $s > 0 advance_pc (offset «_space;2)); else advance_pc (4);
0001 11ss sss0 0000 iiii iiii iiii iiii
Branches if the register is greater than zero
What is BLEZ
what is its encoding, operation and overflow?
Branch on less than or equal to zero
blez $s, offset
if $s <= 0 advance_pc (offset «_space;2)); else advance_pc (4);
0001 10ss sss0 0000 iiii iiii iiii iiii
Branches if the register is less than or equal to zero
What is BLTZ
what is its encoding, operation and overflow?
Branch on less than zero
bltz $s, offset
if $s < 0 advance_pc (offset «_space;2)); else advance_pc (4);
0000 01ss sss0 0000 iiii iiii iiii iiii
Branches if the register is less than zero
What is BNE
what is its encoding, operation and overflow?
Branch on not equal
bne $s, $t, offset
if $s != $t advance_pc (offset «_space;2)); else advance_pc (4);
0001 01ss ssst tttt iiii iiii iiii iiii
Branches if the two registers are not equal
What is DIV
what is its encoding, operation and overflow?
Divide
div $s, $t
$LO = $s / $t; $HI = $s % $t; advance_pc (4);
0000 00ss ssst tttt 0000 0000 0001 1010
Divides $s by $t and stores the quotient in $LO and the remainder in $HI
What is DIVU
what is its encoding, operation and overflow?
Divide unsigned
divu $s, $t
$LO = $s / $t; $HI = $s % $t; advance_pc (4);
0000 00ss ssst tttt 0000 0000 0001 1011
Divides $s by $t and stores the quotient in $LO and the remainder in $HI