MIPS32™ Architecture For Programmers
Volume II: The MIPS32™ Instruction Set
Document Number: MD00086
Revision 1.00
August 29, 2002
MIPS Technologies, Inc.
1225 Charleston Road
Mountain View, CA 94043-1353
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.
Copyright © 2001-2002 MIPS Technologies, Inc. All rights reserved.
Unpublished rights (if any) are reserved under the Copyright Laws of the United States of America.
If this document is provided in source format (i.e., in a modifiable form such as in FrameMaker or Microsoft Word format),
then its use and distribution is subject to a written agreement with MIPS Technologies, Inc. ("MIPS Technologies"). UNDER
NO CIRCUMSTANCES MAY A DOCUMENT PROVIDED IN SOURCE FORMAT BE DISTRIBUTED TO A THIRD
PARTY WITHOUT THE EXPRESS WRITTEN CONSENT OF MIPS TECHNOLOGIES.
This document contains information that is proprietary to MIPS Technologies. Any copying, reproducing, modifying, or use of
this information (in whole or in part) which is not expressly permitted in writing by MIPS Technologies or a
contractually-authorized third party is strictly prohibited. At a minimum, this information is protected under unfair competition
and copyright laws. Violations thereof may result in criminal penalties and fines.
MIPS Technologies or any contractually-authorized third party reserves the right to change the information contained in this
document to improve function, design or otherwise. MIPS Technologies does not assume any liability arising out of the
application or use of this information, or of any error of omission in such information. Any warranties, whether express,
statutory, implied or otherwise, including but not limited to the implied warranties of merchantability or fitness for a particular
purpose, are excluded. Any license under patent rights or any other intellectual property rights owned by MIPS Technologies
or third parties shall be conveyed by MIPS Technologies or any contractually-authorized third party in a separate license
agreement between the parties.
The information contained in this document shall not be exported or transferred for the purpose of reexporting in violation of
any U.S. or non-U.S. regulation, treaty, Executive Order, law, statute, amendment or supplement thereto.
The information contained in this document constitutes one or more of the following: commercial computer software,
commercial computer software documentation or other commercial items. If the user of this information, or any related
documentation of any kind, including related technical data or manuals, is an agency, department, or other entity of the United
States government (“Government”), the use, duplication, reproduction, release, modification, disclosure, or transfer of this
information, or any related documentation of any kind, is restricted in accordance with Federal Acquisition Regulation 12.212
for civilian agencies and Defense Federal Acquisition Regulation Supplement 227.7202 for military agencies. The use of this
information by the Government is further restricted in accordance with the terms of the license agreement(s) and/or applicable
contract terms and conditions covering this information from MIPS Technologies or any contractually-authorized third party.
MIPS®, R3000®, R4000®, R5000® and R10000® are among the registered trademarks of MIPS Technologies, Inc. in the
United States and certain other countries, and MIPS16™, MIPS16e™, MIPS32™, MIPS64™, MIPS-3D™, MIPS-based™,
MIPS I™, MIPS II™, MIPS III™, MIPS IV™, MIPS V™, MDMX™, MIPSsim™, MIPSsimCA™, MIPSsimIA™,
QuickMIPS™, SmartMIPS™, MIPS Technologies logo, 4K™, 4Kc™, 4Km™, 4Kp™, 4KE™, 4KEc™, 4KEm™, 4KEp™,
4KS™, 4KSc™, M4K™, 5K™, 5Kc™, 5Kf™, 20K™, 20Kc™, 25Kf™, R4300™, ASMACRO™, ATLAS™, BusBridge™,
CoreFPGA™, CoreLV™, EC™, JALGO™, MALTA™, MGB™, PDtrace™, SEAD™, SEAD-2™, SOC-it™, The Pipeline™,
and YAMON™ are among the trademarks of MIPS Technologies, Inc.
All other trademarks referred to herein are the property of their respective owners.
Template: B1.06, Build with Conditional Tags: 2B ARCH MIPS32
MIPS32™ Architecture For Programmers Volume II, Revision 1.00
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.
Table of Contents
Chapter 1 About This Book ........................................................................................................................................................ 1
1.1 Typographical Conventions ........................................................................................................................................... 1
1.1.1 Italic Text ............................................................................................................................................................. 1
1.1.2 Bold Text ............................................................................................................................................................. 1
1.1.3 Courier Text ......................................................................................................................................................... 1
1.2 UNPREDICTABLE and UNDEFINED ........................................................................................................................ 2
1.2.1 UNPREDICTABLE............................................................................................................................................. 2
1.2.2 UNDEFINED....................................................................................................................................................... 2
1.3 Special Symbols in Pseudocode Notation...................................................................................................................... 2
1.4 For More Information .................................................................................................................................................... 4
Chapter 2 Guide to the Instruction Set ........................................................................................................................................ 7
2.1 Understanding the Instruction Fields ............................................................................................................................. 7
2.1.1 Instruction Fields ................................................................................................................................................. 8
2.1.2 Instruction Descriptive Name and Mnemonic ..................................................................................................... 9
2.1.3 Format Field......................................................................................................................................................... 9
2.1.4 Purpose Field ..................................................................................................................................................... 10
2.1.5 Description Field................................................................................................................................................ 10
2.1.6 Restrictions Field ............................................................................................................................................... 10
2.1.7 Operation Field .................................................................................................................................................. 11
2.1.8 Exceptions Field................................................................................................................................................. 11
2.1.9 Programming Notes and Implementation Notes Fields ..................................................................................... 11
2.2 Operation Section Notation and Functions .................................................................................................................. 12
2.2.1 Instruction Execution Ordering.......................................................................................................................... 12
2.2.2 Pseudocode Functions........................................................................................................................................ 12
2.3 Op and Function Subfield Notation ............................................................................................................................. 20
2.4 FPU Instructions .......................................................................................................................................................... 20
Chapter 3 The MIPS32™ Instruction Set ................................................................................................................................. 21
3.1 Compliance and Subsetting.......................................................................................................................................... 21
3.2 Alphabetical List of Instructions.................................................................................................................................. 22
ABS.fmt ............................................................................................................................................................................................................................... 30
ADD..................................................................................................................................................................................................................................... 31
ADD.fmt .............................................................................................................................................................................................................................. 32
ADDI.................................................................................................................................................................................................................................... 33
ADDIU................................................................................................................................................................................................................................. 34
ADDU .................................................................................................................................................................................................................................. 35
AND..................................................................................................................................................................................................................................... 36
ANDI.................................................................................................................................................................................................................................... 37
B........................................................................................................................................................................................................................................... 38
BAL...................................................................................................................................................................................................................................... 39
BC1F.................................................................................................................................................................................................................................... 40
BC1FL ................................................................................................................................................................................................................................. 42
BC1T.................................................................................................................................................................................................................................... 44
BC1TL ................................................................................................................................................................................................................................. 46
BC2F.................................................................................................................................................................................................................................... 48
BC2FL ................................................................................................................................................................................................................................. 49
BC2T.................................................................................................................................................................................................................................... 51
BC2TL ................................................................................................................................................................................................................................. 52
BEQ...................................................................................................................................................................................................................................... 54
BEQL ................................................................................................................................................................................................................................... 55
BGEZ ................................................................................................................................................................................................................................... 57
BGEZAL.............................................................................................................................................................................................................................. 58
BGEZALL ........................................................................................................................................................................................................................... 59
BGEZL................................................................................................................................................................................................................................. 61
MIPS32™ Architecture For Programmers Volume II, Revision 1.00
i
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.
BGTZ ................................................................................................................................................................................................................................... 63
BGTZL................................................................................................................................................................................................................................. 64
BLEZ.................................................................................................................................................................................................................................... 66
BLEZL ................................................................................................................................................................................................................................. 67
BLTZ.................................................................................................................................................................................................................................... 69
BLTZAL .............................................................................................................................................................................................................................. 70
BLTZALL............................................................................................................................................................................................................................ 71
BLTZL ................................................................................................................................................................................................................................. 73
BNE...................................................................................................................................................................................................................................... 75
BNEL ................................................................................................................................................................................................................................... 76
BREAK................................................................................................................................................................................................................................ 78
C.cond.fmt............................................................................................................................................................................................................................ 79
CACHE................................................................................................................................................................................................................................ 84
CEIL.W.fmt ......................................................................................................................................................................................................................... 91
CFC1.................................................................................................................................................................................................................................... 92
CFC2.................................................................................................................................................................................................................................... 94
CLO...................................................................................................................................................................................................................................... 95
CLZ...................................................................................................................................................................................................................................... 96
COP2.................................................................................................................................................................................................................................... 97
CTC1.................................................................................................................................................................................................................................... 98
CTC2.................................................................................................................................................................................................................................. 100
CVT.D.fmt ......................................................................................................................................................................................................................... 101
CVT.S.fmt.......................................................................................................................................................................................................................... 102
CVT.W.fmt ........................................................................................................................................................................................................................ 103
DERET............................................................................................................................................................................................................................... 104
DIV .................................................................................................................................................................................................................................... 106
DIV.fmt.............................................................................................................................................................................................................................. 108
DIVU.................................................................................................................................................................................................................................. 109
ERET.................................................................................................................................................................................................................................. 110
FLOOR.W.fmt ................................................................................................................................................................................................................... 111
J.......................................................................................................................................................................................................................................... 112
JAL..................................................................................................................................................................................................................................... 113
JALR.................................................................................................................................................................................................................................. 114
JR ....................................................................................................................................................................................................................................... 116
LB ...................................................................................................................................................................................................................................... 118
LBU.................................................................................................................................................................................................................................... 119
LDC1.................................................................................................................................................................................................................................. 120
LDC2.................................................................................................................................................................................................................................. 121
LH ...................................................................................................................................................................................................................................... 122
LHU ................................................................................................................................................................................................................................... 123
LL....................................................................................................................................................................................................................................... 124
LUI..................................................................................................................................................................................................................................... 126
LW ..................................................................................................................................................................................................................................... 127
LWC1................................................................................................................................................................................................................................. 128
LWC2................................................................................................................................................................................................................................. 129
LWL................................................................................................................................................................................................................................... 130
LWR................................................................................................................................................................................................................................... 133
MADD ............................................................................................................................................................................................................................... 137
MADDU ............................................................................................................................................................................................................................ 138
MFC0 ................................................................................................................................................................................................................................. 139
MFC1 ................................................................................................................................................................................................................................. 140
MFC2 ................................................................................................................................................................................................................................. 141
MFHI.................................................................................................................................................................................................................................. 142
MFLO ................................................................................................................................................................................................................................ 143
MOV.fmt............................................................................................................................................................................................................................ 144
MOVF................................................................................................................................................................................................................................ 145
MOVF.fmt ......................................................................................................................................................................................................................... 146
MOVN ............................................................................................................................................................................................................................... 148
MOVN.fmt......................................................................................................................................................................................................................... 149
MOVT................................................................................................................................................................................................................................ 151
MOVT.fmt ......................................................................................................................................................................................................................... 152
MOVZ................................................................................................................................................................................................................................ 154
MOVZ.fmt ......................................................................................................................................................................................................................... 155
MSUB ................................................................................................................................................................................................................................ 157
MSUBU ............................................................................................................................................................................................................................. 158
MTC0................................................................................................................................................................................................................................. 159
ii
MIPS32™ Architecture For Programmers Volume II, Revision 1.00
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.
MTC1................................................................................................................................................................................................................................. 160
MTC2................................................................................................................................................................................................................................. 161
MTHI ................................................................................................................................................................................................................................. 162
MTLO ................................................................................................................................................................................................................................ 163
MUL................................................................................................................................................................................................................................... 164
MUL.fmt ............................................................................................................................................................................................................................ 165
MULT ................................................................................................................................................................................................................................ 166
MULTU ............................................................................................................................................................................................................................. 167
NEG.fmt............................................................................................................................................................................................................................. 168
NOP.................................................................................................................................................................................................................................... 169
NOR ................................................................................................................................................................................................................................... 170
OR...................................................................................................................................................................................................................................... 171
ORI..................................................................................................................................................................................................................................... 172
PREF.................................................................................................................................................................................................................................. 173
ROUND.W.fmt .................................................................................................................................................................................................................. 177
SB....................................................................................................................................................................................................................................... 179
SC....................................................................................................................................................................................................................................... 180
SDBBP............................................................................................................................................................................................................................... 183
SDC1.................................................................................................................................................................................................................................. 184
SDC2.................................................................................................................................................................................................................................. 185
SH ...................................................................................................................................................................................................................................... 186
SLL .................................................................................................................................................................................................................................... 187
SLLV.................................................................................................................................................................................................................................. 188
SLT .................................................................................................................................................................................................................................... 189
SLTI ................................................................................................................................................................................................................................... 190
SLTIU ................................................................................................................................................................................................................................ 191
SLTU.................................................................................................................................................................................................................................. 192
SQRT.fmt........................................................................................................................................................................................................................... 193
SRA.................................................................................................................................................................................................................................... 194
SRAV................................................................................................................................................................................................................................. 195
SRL .................................................................................................................................................................................................................................... 196
SRLV ................................................................................................................................................................................................................................. 197
SSNOP ............................................................................................................................................................................................................................... 198
SUB.................................................................................................................................................................................................................................... 199
SUB.fmt ............................................................................................................................................................................................................................. 200
SUBU................................................................................................................................................................................................................................. 201
SW...................................................................................................................................................................................................................................... 202
SWC1................................................................................................................................................................................................................................. 203
SWC2................................................................................................................................................................................................................................. 204
SWL ................................................................................................................................................................................................................................... 205
SWR................................................................................................................................................................................................................................... 207
SYNC................................................................................................................................................................................................................................. 209
SYSCALL.......................................................................................................................................................................................................................... 213
TEQ.................................................................................................................................................................................................................................... 214
TEQI .................................................................................................................................................................................................................................. 215
TGE.................................................................................................................................................................................................................................... 216
TGEI .................................................................................................................................................................................................................................. 217
TGEIU................................................................................................................................................................................................................................ 218
TGEU................................................................................................................................................................................................................................. 219
TLBP.................................................................................................................................................................................................................................. 220
TLBR ................................................................................................................................................................................................................................. 221
TLBWI............................................................................................................................................................................................................................... 223
TLBWR.............................................................................................................................................................................................................................. 225
TLT .................................................................................................................................................................................................................................... 227
TLTI................................................................................................................................................................................................................................... 228
TLTIU ................................................................................................................................................................................................................................ 229
TLTU ................................................................................................................................................................................................................................. 230
TNE.................................................................................................................................................................................................................................... 231
TNEI .................................................................................................................................................................................................................................. 232
TRUNC.W.fmt................................................................................................................................................................................................................... 233
WAIT ................................................................................................................................................................................................................................. 235
XOR ................................................................................................................................................................................................................................... 237
XORI.................................................................................................................................................................................................................................. 238
Appendix A Instruction Bit Encodings ................................................................................................................................... 239
A.1 Instruction Encodings and Instruction Classes ......................................................................................................... 239
MIPS32™ Architecture For Programmers Volume II, Revision 1.00
iii
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.
A.2 Instruction Bit Encoding Tables................................................................................................................................ 239
A.3 Floating Point Unit Instruction Format Encodings ................................................................................................... 244
Appendix B Revision History ................................................................................................................................................. 245
iv
MIPS32™ Architecture For Programmers Volume II, Revision 1.00
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.
List of Figures
Figure 2-1: Example of Instruction Description .......................................................................................................................... 8
Figure 2-2: Example of Instruction Fields ................................................................................................................................... 9
Figure 2-3: Example of Instruction Descriptive Name and Mnemonic ....................................................................................... 9
Figure 2-4: Example of Instruction Format.................................................................................................................................. 9
Figure 2-5: Example of Instruction Purpose .............................................................................................................................. 10
Figure 2-6: Example of Instruction Description ........................................................................................................................ 10
Figure 2-7: Example of Instruction Restrictions ........................................................................................................................ 11
Figure 2-8: Example of Instruction Operation ........................................................................................................................... 11
Figure 2-9: Example of Instruction Exception........................................................................................................................... 11
Figure 2-10: Example of Instruction Programming Notes......................................................................................................... 12
Figure 2-11: COP_LW Pseudocode Function............................................................................................................................ 13
Figure 2-12: COP_LD Pseudocode Function............................................................................................................................. 13
Figure 2-13: COP_SW Pseudocode Function............................................................................................................................ 13
Figure 2-14: COP_SD Pseudocode Function............................................................................................................................. 14
Figure 2-15: AddressTranslation Pseudocode Function ............................................................................................................ 14
Figure 2-16: LoadMemory Pseudocode Function...................................................................................................................... 15
Figure 2-17: StoreMemory Pseudocode Function ..................................................................................................................... 15
Figure 2-18: Prefetch Pseudocode Function .............................................................................................................................. 16
Figure 2-19: ValueFPR Pseudocode Function ........................................................................................................................... 17
Figure 2-20: StoreFPR Pseudocode Function ............................................................................................................................ 17
Figure 2-21: SyncOperation Pseudocode Function.................................................................................................................... 18
Figure 2-22: SignalException Pseudocode Function ................................................................................................................. 18
Figure 2-23: SignalDebugBreakpointException Pseudocode Function..................................................................................... 18
Figure 2-24: SignalDebugModeBreakpointException Pseudocode Function ........................................................................... 18
Figure 2-25: NullifyCurrentInstruction PseudoCode Function.................................................................................................. 19
Figure 2-26: CoprocessorOperation Pseudocode Function........................................................................................................ 19
Figure 2-27: JumpDelaySlot Pseudocode Function ................................................................................................................... 19
Figure 2-28: FPConditionCode Pseudocode Function............................................................................................................... 20
Figure 2-29: SetFPConditionCode Pseudocode Function.......................................................................................................... 20
Figure 3-1: Usage of Address Fields to Select Index and Way ................................................................................................. 85
Figure 3-2: Unaligned Word Load Using LWL and LWR ...................................................................................................... 130
Figure 3-3: Bytes Loaded by LWL Instruction........................................................................................................................ 131
Figure 3-4: Unaligned Word Load Using LWL and LWR ...................................................................................................... 134
Figure 3-5: Bytes Loaded by LWL Instruction........................................................................................................................ 135
Figure 3-6: Unaligned Word Store Using SWL and SWR ...................................................................................................... 205
Figure 3-7: Bytes Stored by an SWL Instruction..................................................................................................................... 206
Figure 3-8: Unaligned Word Store Using SWR and SWL ...................................................................................................... 207
Figure 3-9: Bytes Stored by SWR Instruction ......................................................................................................................... 208
Figure A-1: Sample Bit Encoding Table.................................................................................................................................. 240
MIPS32™ Architecture For Programmers Volume II, Revision 1.00
v
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.
List of Tables
Table 1-1: Symbols Used in Instruction Operation Statements .................................................................................................. 2
Table 2-1: AccessLength Specifications for Loads/Stores ....................................................................................................... 16
Table 3-1: CPU Arithmetic Instructions ................................................................................................................................... 22
Table 3-2: CPU Branch and Jump Instructions......................................................................................................................... 22
Table 3-3: CPU Instruction Control Instructions ...................................................................................................................... 23
Table 3-4: CPU Load, Store, and Memory Control Instructions .............................................................................................. 23
Table 3-5: CPU Logical Instructions ........................................................................................................................................ 24
Table 3-6: CPU Move Instructions ........................................................................................................................................... 24
Table 3-7: CPU Shift Instructions............................................................................................................................................. 24
Table 3-8: CPU Trap Instructions ............................................................................................................................................. 25
Table 3-9: Obsolete CPU Branch Instructions.......................................................................................................................... 25
Table 3-10: FPU Arithmetic Instructions.................................................................................................................................. 26
Table 3-11: FPU Branch Instructions........................................................................................................................................ 26
Table 3-12: FPU Compare Instructions .................................................................................................................................... 26
Table 3-13: FPU Convert Instructions ...................................................................................................................................... 26
Table 3-14: FPU Load, Store, and Memory Control Instructions............................................................................................. 27
Table 3-15: FPU Move Instructions.......................................................................................................................................... 27
Table 3-16: Obsolete FPU Branch Instructions ........................................................................................................................ 27
Table 3-17: Coprocessor Branch Instructions........................................................................................................................... 27
Table 3-18: Coprocessor Execute Instructions.......................................................................................................................... 27
Table 3-19: Coprocessor Load and Store Instructions .............................................................................................................. 28
Table 3-20: Coprocessor Move Instructions ............................................................................................................................. 28
Table 3-21: Obsolete Coprocessor Branch Instructions............................................................................................................ 28
Table 3-22: Privileged Instructions ........................................................................................................................................... 28
Table 3-23: EJTAG Instructions ............................................................................................................................................... 29
Table 3-24: FPU Comparisons Without Special Operand Exceptions ..................................................................................... 80
Table 3-25: FPU Comparisons With Special Operand Exceptions for QNaNs........................................................................ 81
Table 3-26: Usage of Effective Address ................................................................................................................................... 84
Table 3-27: Encoding of Bits[17:16] of CACHE Instruction ................................................................................................... 85
Table 3-28: Encoding of Bits [20:18] of the CACHE Instruction ............................................................................................ 86
Table 3-29: Values of the hint Field for the PREF Instruction ............................................................................................... 174
Table A-1: Symbols Used in the Instruction Encoding Tables............................................................................................... 240
Table A-2: MIPS32 Encoding of the Opcode Field................................................................................................................ 241
Table A-3: MIPS32 SPECIAL Opcode Encoding of Function Field ..................................................................................... 241
Table A-4: MIPS32 REGIMM Encoding of rt Field .............................................................................................................. 241
Table A-5: MIPS32 SPECIAL2 Encoding of Function Field................................................................................................. 242
Table A-6: MIPS32 MOVCI Encoding of tf Bit..................................................................................................................... 242
Table A-7: MIPS32 COPz Encoding of rs Field..................................................................................................................... 242
Table A-8: MIPS32 COPz Encoding of rt Field When rs=BCz ............................................................................................. 242
Table A-9: MIPS32 COP0 Encoding of rs Field..................................................................................................................... 242
Table A-10: MIPS32 COP0 Encoding of Function Field When rs=CO ................................................................................. 243
Table A-11: MIPS32 COP1 Encoding of rs Field................................................................................................................... 243
Table A-12: MIPS32 COP1 Encoding of Function Field When rs=S .................................................................................... 243
Table A-13: MIPS32 COP1 Encoding of Function Field When rs=D.................................................................................... 243
Table A-14: MIPS32 COP1 Encoding of Function Field When rs=W................................................................................... 244
Table A-15: MIPS32 COP1 Encoding of tf Bit When rs=S, D, or PS, Function=MOVCF ................................................... 244
Table 3-30: Floating Point Unit Instruction Format Encodings.............................................................................................. 244
vi
MIPS32™ Architecture For Programmers Volume II, Revision 1.00
Copyright © 2001-2002 MIPS Technologies Inc. All rights reserved.