MIPS Instruction ref Flashcards
(45 cards)
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
What is JAL
what is its encoding, operation and overflow?
Jump and link
jal target
$31 = PC + 8 (or nPC + 4); PC = nPC; nPC = (PC & 0xf0000000) | (target «_space;2);
0000 11ii iiii iiii iiii iiii iiii iiii
Jumps to the calculated address and stores the return address in $31
What is JR
what is its encoding, operation and overflow?
Jump register
jr $s
PC = nPC; nPC = $s;
0000 00ss sss0 0000 0000 0000 0000 1000
Jump to the address contained in register $s
What is LB
what is its encoding, operation and overflow?
Load byte
lb $t, offset($s)
$t = MEM[$s + offset]; advance_pc (4);
1000 00ss ssst tttt iiii iiii iiii iiii
A byte is loaded into a register from the specified address.
What is LUI
what is its encoding, operation and overflow?
Load upper immediate
lui $t, imm
$t = (imm «_space;16); advance_pc (4);
0011 11– —t tttt iiii iiii iiii iiii
The immediate value is shifted left 16 bits and stored in the register. The lower 16 bits are zeroes.
What is LW
what is its encoding, operation and overflow?
Load word
lw $t, offset($s)
$t = MEM[$s + offset]; advance_pc (4);
1000 11ss ssst tttt iiii iiii iiii iiii
A word is loaded into a register from the specified address.
What is MFHI
what is its encoding, operation and overflow?
Move from HI
mfhi $d
$d = $HI; advance_pc (4);
0000 0000 0000 0000 dddd d000 0001 0000
The contents of register HI are moved to the specified register.