Difference between revisions of "R3000 instruction set"
Line 6: | Line 6: | ||
The first paragraph of an instruction's description should be a short one-liner. It will be used as the tooltip. Think "reminder", rather than "explanation". | The first paragraph of an instruction's description should be a short one-liner. It will be used as the tooltip. Think "reminder", rather than "explanation". | ||
+ | |||
+ | These are stolen from Wikipedia. Whoops. | ||
+ | |||
+ | ==== nop ==== | ||
+ | |||
+ | No operation | ||
+ | |||
+ | Used to cause delays between instructions, because some instructions step on each other's toes. | ||
+ | |||
+ | Example: | ||
+ | nop | ||
+ | |||
+ | === Arithmetic === | ||
+ | |||
+ | These instructions act on registers as 32-bit two's-complement integers. | ||
==== add ==== | ==== add ==== | ||
Line 76: | Line 91: | ||
Example: | Example: | ||
divu $s, $t | divu $s, $t | ||
+ | |||
+ | === Memory === | ||
+ | |||
+ | Getting data from/to the RAM. | ||
==== lw ==== | ==== lw ==== | ||
Line 154: | Line 173: | ||
mflo $d | mflo $d | ||
− | === | + | === Comparison === |
− | + | Comparing numbers. | |
+ | |||
+ | Set $d to 1 if true, 0 if false. | ||
+ | |||
+ | ==== slt ==== | ||
+ | |||
+ | Set on less than | ||
Example: | Example: | ||
− | + | slt $d,$s,$t | |
− | ==== | + | ==== slti ==== |
− | + | Set on less than immediate | |
Example: | Example: | ||
− | + | slti $t,$s,C | |
+ | |||
+ | === Binary === | ||
+ | |||
+ | These instructions act on registers as sequences of 0's and 1's. | ||
==== and ==== | ==== and ==== | ||
Line 209: | Line 238: | ||
Example: | Example: | ||
nor $d,$s,$t | nor $d,$s,$t | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==== sll ==== | ==== sll ==== | ||
Line 265: | Line 280: | ||
Example: | Example: | ||
srav $d,$t,$s | srav $d,$t,$s | ||
+ | |||
+ | === Control === | ||
+ | |||
+ | These instructions may or will cause a jump to a different part of the program. | ||
+ | |||
+ | The instruction right after one of these will always be executed, even if there's a jump. | ||
==== beq ==== | ==== beq ==== | ||
Line 300: | Line 321: | ||
Example: | Example: | ||
jal C | jal C | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 08:02, 27 July 2014
Contents
Intro
Instructions
Note: This section is meant to be linked to, and used to generate tooltips (title text) for code pages.
The first paragraph of an instruction's description should be a short one-liner. It will be used as the tooltip. Think "reminder", rather than "explanation".
These are stolen from Wikipedia. Whoops.
nop
No operation
Used to cause delays between instructions, because some instructions step on each other's toes.
Example:
nop
Arithmetic
These instructions act on registers as 32-bit two's-complement integers.
add
Add
Example:
add $d,$s,$t
addu
Add unsigned
Example:
addu $d,$s,$t
sub
Subtract
Example:
sub $d,$s,$t
subu
Subtract unsigned
Example:
subu $d,$s,$t
addi
Add immediate
Example:
addi $t,$s,C
addiu
Add immediate unsigned
Example:
addiu $t,$s,C
mult
Multiply
Example:
mult $s,$t
multu
Multiply unsigned
Example:
multu $s,$t
div
Divide
Example:
div $s, $t
divu
Divide unsigned
Example:
divu $s, $t
Memory
Getting data from/to the RAM.
lw
Load word
Example:
lw $t,C($s)
lh
Load halfword
Example:
lh $t,C($s)
lhu
Load halfword unsigned
Example:
lhu $t,C($s)
lb
Load byte
Example:
lb $t,C($s)
lbu
Load byte unsigned
Example:
lbu $t,C($s)
sw
Store word
Example:
sw $t,C($s)
sh
Store half
Example:
sh $t,C($s)
sb
Store byte
Example:
sb $t,C($s)
lui
Load upper immediate
Example:
lui $t,C
mfhi
Move from high
Example:
mfhi $d
mflo
Move from low
Example:
mflo $d
Comparison
Comparing numbers.
Set $d to 1 if true, 0 if false.
slt
Set on less than
Example:
slt $d,$s,$t
slti
Set on less than immediate
Example:
slti $t,$s,C
Binary
These instructions act on registers as sequences of 0's and 1's.
and
And
Example:
and $d,$s,$t
andi
And immediate
Example:
andi $t,$s,C
or
Or
Example:
or $d,$s,$t
ori
Or immediate
Example:
ori $t,$s,C
xor
Exclusive or
Example:
xor $d,$s,$t
nor
Nor
Example:
nor $d,$s,$t
sll
Shift left logical immediate
Example:
sll $d,$t,shamt
srl
Shift right logical immediate
Example:
srl $d,$t,shamt
sra
Shift right arithmetic immediate
Example:
sra $d,$t,shamt
sllv
Shift left logical
Example:
sllv $d,$t,$s
srlv
Shift right logical
Example:
srlv $d,$t,$s
srav
Shift right arithmetic
Example:
srav $d,$t,$s
Control
These instructions may or will cause a jump to a different part of the program.
The instruction right after one of these will always be executed, even if there's a jump.
beq
Branch on equal
Example:
beq $s,$t,C
bne
Branch on not equal
Example:
bne $s,$t,C
j
Jump
Example:
j C
jr
Jump register
Example:
jr $s
jal
Jump and link
Example:
jal C