{ "@context": "https://schema.org", "@type": "Organization", "name": "Brainscape", "url": "https://www.brainscape.com/", "logo": "https://www.brainscape.com/pks/images/cms/public-views/shared/Brainscape-logo-c4e172b280b4616f7fda.svg", "sameAs": [ "https://www.facebook.com/Brainscape", "https://x.com/brainscape", "https://www.linkedin.com/company/brainscape", "https://www.instagram.com/brainscape/", "https://www.tiktok.com/@brainscapeu", "https://www.pinterest.com/brainscape/", "https://www.youtube.com/@BrainscapeNY" ], "contactPoint": { "@type": "ContactPoint", "telephone": "(929) 334-4005", "contactType": "customer service", "availableLanguage": ["English"] }, "founder": { "@type": "Person", "name": "Andrew Cohen" }, "description": "Brainscape’s spaced repetition system is proven to DOUBLE learning results! Find, make, and study flashcards online or in our mobile app. Serious learners only.", "address": { "@type": "PostalAddress", "streetAddress": "159 W 25th St, Ste 517", "addressLocality": "New York", "addressRegion": "NY", "postalCode": "10001", "addressCountry": "USA" } }

MIPS Instruction ref Flashcards

(45 cards)

1
Q

The manner in which the processor executes an instruction and advances its program counters is as follows:

A

execute the instruction at PC
copy nPC to PC
add 4 or the branch offset to nPC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between signed and unsigned instructions?

A

The only difference between signed and unsigned instructions is that signed instructions can generate an overflow exception and unsigned instructions can not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What kind of values are arithmetic immediate values?

A

ALL arithmetic immediate values are sign-extended.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is ADD

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is ADDI

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is ADDIU

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is ADDU

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is AND

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is ANDI

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is BEQ

what is its encoding, operation and overflow?

A

Branch on equal

beq $s, $t, offset

if $s == $t advance_pc (offset &laquo_space;2)); else advance_pc (4);

0001 00ss ssst tttt iiii iiii iiii iiii

Branches if the two registers are equal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is BGEZ

what is its encoding, operation and overflow?

A

Branch on greater than or equal to zero

bgez $s, offset

if $s >= 0 advance_pc (offset &laquo_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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is BGEZAL

what is its encoding, operation and overflow?

A

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 &laquo_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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is BGTZ

what is its encoding, operation and overflow?

A

Branch on greater than zero

bgtz $s, offset

if $s > 0 advance_pc (offset &laquo_space;2)); else advance_pc (4);

0001 11ss sss0 0000 iiii iiii iiii iiii

Branches if the register is greater than zero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is BLEZ

what is its encoding, operation and overflow?

A

Branch on less than or equal to zero

blez $s, offset

if $s <= 0 advance_pc (offset &laquo_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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is BLTZ

what is its encoding, operation and overflow?

A

Branch on less than zero

bltz $s, offset

if $s < 0 advance_pc (offset &laquo_space;2)); else advance_pc (4);

0000 01ss sss0 0000 iiii iiii iiii iiii

Branches if the register is less than zero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is BNE

what is its encoding, operation and overflow?

A

Branch on not equal

bne $s, $t, offset

if $s != $t advance_pc (offset &laquo_space;2)); else advance_pc (4);

0001 01ss ssst tttt iiii iiii iiii iiii

Branches if the two registers are not equal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is DIV

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is DIVU

what is its encoding, operation and overflow?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is JAL

what is its encoding, operation and overflow?

A

Jump and link

jal target

$31 = PC + 8 (or nPC + 4); PC = nPC; nPC = (PC & 0xf0000000) | (target &laquo_space;2);

0000 11ii iiii iiii iiii iiii iiii iiii

Jumps to the calculated address and stores the return address in $31

20
Q

What is JR

what is its encoding, operation and overflow?

A

Jump register

jr $s

PC = nPC; nPC = $s;

0000 00ss sss0 0000 0000 0000 0000 1000

Jump to the address contained in register $s

21
Q

What is LB

what is its encoding, operation and overflow?

A

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.

22
Q

What is LUI

what is its encoding, operation and overflow?

A

Load upper immediate

lui $t, imm

$t = (imm &laquo_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.

23
Q

What is LW

what is its encoding, operation and overflow?

A

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.

24
Q

What is MFHI

what is its encoding, operation and overflow?

A

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.

25
What is MFLO what is its encoding, operation and overflow?
Move from LO mflo $d $d = $LO; advance_pc (4); 0000 0000 0000 0000 dddd d000 0001 0010 The contents of register LO are moved to the specified register.
26
What is MULT what is its encoding, operation and overflow?
Multiply mult $s, $t $LO = $s * $t; advance_pc (4); 0000 00ss ssst tttt 0000 0000 0001 1000 Multiplies $s by $t and stores the result in $LO.
27
What is MULTU what is its encoding, operation and overflow?
Multiply unsigned multu $s, $t $LO = $s * $t; advance_pc (4); 0000 00ss ssst tttt 0000 0000 0001 1001 Multiplies $s by $t and stores the result in $LO.
28
What is NOOP what is its encoding, operation and overflow?
no operation noop advance_pc (4); 0000 0000 0000 0000 0000 0000 0000 0000 Performs no operation.
29
What is OR what is its encoding, operation and overflow?
Bitwise or or $d, $s, $t $d = $s | $t; advance_pc (4); 0000 00ss ssst tttt dddd d000 0010 0101 Bitwise logical ors two registers and stores the result in a register
30
What is ORI what is its encoding, operation and overflow?
Bitwise or immediate ori $t, $s, imm $t = $s | imm; advance_pc (4); 0011 01ss ssst tttt iiii iiii iiii iiii Bitwise ors a register and an immediate value and stores the result in a register
31
What is SB what is its encoding, operation and overflow?
Store byte sb $t, offset($s) MEM[$s + offset] = (0xff & $t); advance_pc (4); 1010 00ss ssst tttt iiii iiii iiii iiii The least significant byte of $t is stored at the specified address.
32
What is SLL what is its encoding, operation and overflow?
Shift left logical sll $d, $t, h $d = $t << h; advance_pc (4); 0000 00ss ssst tttt dddd dhhh hh00 0000 Shifts a register value left by the shift amount listed in the instruction and places the result in a third register. Zeroes are shifted in.
33
What is SLLV what is its encoding, operation and overflow?
Shift left logical variable sllv $d, $t, $s $d = $t << $s; advance_pc (4); 0000 00ss ssst tttt dddd d--- --00 0100 Shifts a register value left by the value in a second register and places the result in a third register. Zeroes are shifted in.
34
What is SLT what is its encoding, operation and overflow?
Set on less than (signed) slt $d, $s, $t if $s < $t $d = 1; advance_pc (4); else $d = 0; advance_pc (4); 0000 00ss ssst tttt dddd d000 0010 1010 If $s is less than $t, $d is set to one. It gets zero otherwise.
35
What is SLTI what is its encoding, operation and overflow?
Set on less than immediate (signed) slti $t, $s, imm if $s < imm $t = 1; advance_pc (4); else $t = 0; advance_pc (4); 0010 10ss ssst tttt iiii iiii iiii iiii If $s is less than immediate, $t is set to one. It gets zero otherwise.
36
What is SLTU what is its encoding, operation and overflow?
Set on less than unsigned sltu $d, $s, $t if $s < $t $d = 1; advance_pc (4); else $d = 0; advance_pc (4); 0000 00ss ssst tttt dddd d000 0010 1011 If $s is less than $t, $d is set to one. It gets zero otherwise.
37
What is SRA what is its encoding, operation and overflow?
Shift right arithmetic sra $d, $t, h $d = $t >> h; advance_pc (4); 0000 00-- ---t tttt dddd dhhh hh00 0011 Shifts a register value right by the shift amount (shamt) and places the value in the destination register. The sign bit is shifted in.
38
What is SRL what is its encoding, operation and overflow?
Shift right logical srl $d, $t, h $d = $t >> h; advance_pc (4); 0000 00-- ---t tttt dddd dhhh hh00 0010 Shifts a register value right by the shift amount (shamt) and places the value in the destination register. Zeroes are shifted in.
39
What is SRLV what is its encoding, operation and overflow?
Shift right logical variable srlv $d, $t, $s $d = $t >> $s; advance_pc (4); 0000 00ss ssst tttt dddd d000 0000 0110 Shifts a register value right by the amount specified in $s and places the value in the destination register. Zeroes are shifted in.
40
What is SUB what is its encoding, operation and overflow?
Subtract sub $d, $s, $t $d = $s - $t; advance_pc (4); 0000 00ss ssst tttt dddd d000 0010 0010 Subtracts two registers and stores the result in a register
41
What is SUBU what is its encoding, operation and overflow?
Subtract unsigned subu $d, $s, $t $d = $s - $t; advance_pc (4); 0000 00ss ssst tttt dddd d000 0010 0011 Subtracts two registers and stores the result in a register
42
What is SW what is its encoding, operation and overflow?
Store word sw $t, offset($s) MEM[$s + offset] = $t; advance_pc (4); 1010 11ss ssst tttt iiii iiii iiii iiii The contents of $t is stored at the specified address.
43
What is SYSCALL what is its encoding, operation and overflow?
System call syscall advance_pc (4); 0000 00-- ---- ---- ---- ---- --00 1100 Generates a software interrupt.
44
What is XOR what is its encoding, operation and overflow?
Bitwise exclusive or xor $d, $s, $t $d = $s ^ $t; advance_pc (4); 0000 00ss ssst tttt dddd d--- --10 0110 Exclusive ors two registers and stores the result in a register
45
What is XORI what is its encoding, operation and overflow?
Bitwise exclusive or immediate xori $t, $s, imm $t = $s ^ imm; advance_pc (4); 0011 10ss ssst tttt iiii iiii iiii iiii Bitwise exclusive ors a register and an immediate value and stores the result in a register