For example, UNPREDICTABLE operations executed in user mode must not access memory or internal state that is only accessible in Kernel Mode or Debug Mode or inanother process • UNPREDICT
Trang 1Document Number: MD00076
Revision 2.60 June 25, 2008
MIPS Technologies, Inc.
1225 Charleston Road Mountain View, CA 94043-1353
Copyright © 2001-2003,2005,2008 MIPS Technologies Inc All rights reserved.
MIPS32® Architecture for Programmers Volume IV-a: The MIPS16e™ Application-
Specific Extension to the MIPS32®
Architecture
Trang 2Template: nB1.03, Built with tags: 2B ARCH MIPS32
This document contains information that is proprietary to MIPS Technologies, Inc ("MIPS Technologies") Any copying, reproducing, modifying or use of this information (in whole or in part) that is not expressly permitted in writing by MIPS Technologies or an 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.
Any document provided in source format (i.e., in a modifiable form such as in FrameMaker or Microsoft Word format) is subject to use and distribution restrictions that are independent of and supplemental to any and all confidentiality restrictions UNDER NO CIRCUMSTANCES MAY A DOCUMENT PROVIDED IN SOURCE FORMAT BE DISTRIBUTED TO A THIRD PARTY IN SOURCE FORMAT WITHOUT THE EXPRESS WRITTEN PERMISSION OF MIPS TECHNOLOGIES, INC.
MIPS Technologies 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 or 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 Except as expressly provided in any written license agreement from MIPS Technologies or an authorized third party, the furnishing of this document does not give recipient any license to any intellectual property rights, including any patent rights, that cover the information in this document.
The information contained in this document shall not be exported, reexported, transferred, or released, directly or indirectly, in violation of the law of any country or international law, regulation, treaty, Executive Order, statute, amendments or supplements thereto Should a conflict arise regarding the export, reexport, transfer, or release of the information contained in this document, the laws of the United States of America shall be the governing law.
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 an authorized third party.
MIPS, MIPS I, MIPS II, MIPS III, MIPS IV, MIPS V, MIPS-3D, MIPS16, MIPS16e, MIPS32, MIPS64, MIPS-Based, MIPSsim, MIPSpro, MIPS Technologies logo, MIPS-VERIFIED, MIPS-VERIFIED logo, 4K, 4Kc, 4Km, 4Kp, 4KE, 4KEc, 4KEm, 4KEp, 4KS, 4KSc, 4KSd, M4K, 5K, 5Kc, 5Kf, 24K, 24Kc, 24Kf, 24KE, 24KEc, 24KEf, 34K, 34Kc, 34Kf, 74K, 74Kc, 74Kf, 1004K, 1004Kc, 1004Kf, R3000, R4000, R5000, ASMACRO, Atlas, "At the core of the user experience.", BusBridge, Bus Navigator, CLAM, CorExtend, CoreFPGA, CoreLV, EC, FPGA View, FS2, FS2 FIRST SILICON SOLUTIONS logo, FS2 NAVIGATOR, HyperDebug, HyperJTAG, JALGO, Logic Navigator, Malta, MDMX, MED, MGB, OCI, PDtrace, the Pipeline, Pro Series, SEAD, SEAD-2, SmartMIPS, SOC-it, System Navigator, and YAMON are trademarks or registered trademarks of MIPS Technologies, Inc in the United States and other countries.
All other trademarks referred to herein are the property of their respective owners.
Trang 3Chapter 1: About This Book 9
1.1: Typographical Conventions 9
1.1.1: Italic Text 9
1.1.2: Bold Text 9
1.1.3: Courier Text 10
1.2: UNPREDICTABLE and UNDEFINED 10
1.2.1: UNPREDICTABLE 10
1.2.2: UNDEFINED 10
1.2.3: UNSTABLE 11
1.3: Special Symbols in Pseudocode Notation 11
1.4: For More Information 13
Chapter 2: Guide to the Instruction Set 15
2.1: Understanding the Instruction Fields 15
2.1.1: Instruction Fields 17
2.1.2: Instruction Descriptive Name and Mnemonic 17
2.1.3: Format Field 17
2.1.4: Purpose Field 18
2.1.5: Description Field 18
2.1.6: Restrictions Field 18
2.1.7: Operation Field 19
2.1.8: Exceptions Field 19
2.1.9: Programming Notes and Implementation Notes Fields 20
2.2: Operation Section Notation and Functions 20
2.2.1: Instruction Execution Ordering 20
2.2.2: Pseudocode Functions 20
2.3: Op and Function Subfield Notation 29
2.4: FPU Instructions 29
Chapter 3: The MIPS16e™ Application-Specific Extension to the MIPS32® Architecture 31
3.1: Base Architecture Requirements 31
3.2: Software Detection of the ASE 31
3.3: Compliance and Subsetting 31
3.4: MIPS16e Overview 31
3.5: MIPS16e ASE Features 32
3.6: MIPS16e Register Set 32
3.7: MIPS16e ISA Modes 34
3.7.1: Modes Available in the MIPS16e Architecture 34
3.7.2: Defining the ISA Mode Field 34
3.7.3: Switching Between Modes When an Exception Occurs 34
3.7.4: Using MIPS16e Jump Instructions to Switch Modes 35
3.8: JALX, JR, JR.HB, JALR and JALR.HB Operations in MIPS16e and MIPS32 Mode 35
3.9: MIPS16e Instruction Summaries 36
3.10: MIPS16e PC-Relative Instructions 38
3.11: MIPS16e Extensible Instructions 39
3.12: MIPS16e Implementation-Definable Macro Instructions 40
3.13: MIPS16e Jump and Branch Instructions 41
Trang 43.14.2: RI-type instruction format 43
3.14.3: RR-type instruction format 43
3.14.4: RRI-type instruction format 43
3.14.5: RRR-type instruction format 43
3.14.6: RRI-A type instruction format 43
3.14.7: Shift instruction format 43
3.14.8: I8-type instruction format 43
3.14.9: I8_MOVR32 instruction format (used only by the MOVR32 instruction) 44
3.14.10: I8_MOV32R instruction format (used only by MOV32R instruction) 44
3.14.11: I8_SVRS instruction format (used only by the SAVE and RESTORE instructions) 44
3.14.12: JAL and JALX instruction format 44
3.14.13: EXT-I instruction format 44
3.14.14: ASMACRO instruction format 44
3.14.15: EXT-RI instruction format 44
3.14.16: EXT-RRI instruction format 44
3.14.17: EXT-RRI-A instruction format 45
3.14.18: EXT-SHIFT instruction format 45
3.14.19: EXT-I8 instruction format 45
3.14.20: EXT-I8_SVRS instruction format (used only by the SAVE and RESTORE instructions) 45
3.15: Instruction Bit Encoding 45
3.16: MIPS16e Instruction Stream Organization and Endianness 48
3.17: MIPS16e Instruction Fetch Restrictions 49
Chapter 4: The MIPS16e™ ASE Instruction Set 51
4.1: MIPS16e™ Instruction Descriptions 51
4.1.1: Pseudocode Functions Specific to MIPS16e™ 51
ADDIU 52
ADDIU 53
ADDIU 54
ADDIU 55
ADDIU 56
ADDIU 57
ADDIU 58
ADDIU 59
ADDIU 60
ADDIU 61
ADDU 62
AND 63
ASMACRO 64
B 65
B 66
BEQZ 67
BEQZ 68
BNEZ 69
BNEZ 70
BREAK 71
BTEQZ 72
BTEQZ 73
BTNEZ 74
BTNEZ 75
CMP 76
Trang 5CMPI 77
CMPI 78
DIV 79
DIVU 81
JAL 82
JALR 83
JALRC 84
JALX 85
JALX 86
JR 87
JR 88
JRC 89
JRC 90
LB 91
LB 92
LBU 93
LBU 94
LH 95
LH 96
LHU 97
LHU 98
LI 99
LI 100
LW 101
LW 102
LW 103
LW 104
LW 105
LW 106
MFHI 107
MFLO 108
MOVE 109
MOVE 110
MULT 111
MULTU 112
NEG 113
NOP 114
NOT 115
OR 116
RESTORE 117
RESTORE 119
SAVE 122
SAVE 124
SB 128
SB 129
SDBBP 130
SEB 131
SEH 132
SH 133
SH 134
SLL 135
SLL 136
SLLV 137
Trang 6SLTI 140
SLTIU 141
SLTIU 142
SLTU 143
SRA 144
SRA 145
SRAV 146
SRL 147
SRL 148
SRLV 149
SUBU 150
SW 151
SW 152
SW 153
SW 154
SW 155
SW 156
XOR 157
ZEB 158
ZEH 159
Appendix A: Revision History 161
Trang 7Figure 2.1: Example of Instruction Description 16
Figure 2.2: Example of Instruction Fields 17
Figure 2.3: Example of Instruction Descriptive Name and Mnemonic 17
Figure 2.4: Example of Instruction Format 17
Figure 2.5: Example of Instruction Purpose 18
Figure 2.6: Example of Instruction Description 18
Figure 2.7: Example of Instruction Restrictions 19
Figure 2.8: Example of Instruction Operation 19
Figure 2.9: Example of Instruction Exception 19
Figure 2.10: Example of Instruction Programming Notes 20
Figure 2.11: COP_LW Pseudocode Function 21
Figure 2.12: COP_LD Pseudocode Function 21
Figure 2.13: COP_SW Pseudocode Function 21
Figure 2.14: COP_SD Pseudocode Function 22
Figure 2.15: CoprocessorOperation Pseudocode Function 22
Figure 2.16: AddressTranslation Pseudocode Function 22
Figure 2.17: LoadMemory Pseudocode Function 23
Figure 2.18: StoreMemory Pseudocode Function 23
Figure 2.19: Prefetch Pseudocode Function 24
Figure 2.20: SyncOperation Pseudocode Function 25
Figure 2.21: ValueFPR Pseudocode Function 25
Figure 2.22: StoreFPR Pseudocode Function 26
Figure 2.23: CheckFPException Pseudocode Function 27
Figure 2.24: FPConditionCode Pseudocode Function 27
Figure 2.25: SetFPConditionCode Pseudocode Function 27
Figure 2.26: SignalException Pseudocode Function 28
Figure 2.27: SignalDebugBreakpointException Pseudocode Function 28
Figure 2.28: SignalDebugModeBreakpointException Pseudocode Function 28
Figure 2.29: NullifyCurrentInstruction PseudoCode Function 29
Figure 2.30: JumpDelaySlot Pseudocode Function 29
Figure 2.31: PolyMult Pseudocode Function 29
Figure 4-1: Xlat Pseudocode Function 51
Trang 8Table 1.1: Symbols Used in Instruction Operation Statements 11
Table 2.1: AccessLength Specifications for Loads/Stores 24
Table 3.1: MIPS16e General-Purpose Registers 33
Table 3.2: MIPS16e Special-Purpose Registers 33
Table 3.3: ISA Mode Bit Encodings 34
Table 3.4: MIPS16e Load and Store Instructions 36
Table 3.5: MIPS16e Save and Restore Instructions 36
Table 3.6: MIPS16e ALU Immediate Instructions 37
Table 3.7: MIPS16e Arithmetic One, Two or Three Operand Register Instructions 37
Table 3.8: MIPS16e Special Instructions 37
Table 3.9: MIPS16e Multiply and Divide Instructions 37
Table 3.10: MIPS16e Jump and Branch Instructions 38
Table 3.11: MIPS16e Shift Instructions 38
Table 3.12: Implementation-Definable Macro Instructions 38
Table 3.13: PC-Relative MIPS16e Instructions 38
Table 3.14: PC-Relative Base Used for Address Calculation 39
Table 3.15: MIPS16e Extensible Instructions 40
Table 3.16: MIPS16e Instruction Fields 41
Table 3.17: Symbols Used in the Instruction Encoding Tables 45
Table 3.18: MIPS16e Encoding of the Opcode Field 46
Table 3.19: MIPS16e JAL(X) Encoding of the x Field 47
Table 3.20: MIPS16e SHIFT Encoding of the f Field 47
Table 3.21: MIPS16e RRI-A Encoding of the f Field 47
Table 3.22: MIPS16e I8 Encoding of the funct Field 47
Table 3.23: MIPS16e RRR Encoding of the f Field 47
Table 3.24: MIPS16e RR Encoding of the Funct Field 48
Table 3.25: MIPS16e I8 Encoding of the s Field when funct=SVRS 48
Table 3.26: MIPS16e RR Encoding of the ry Field when funct=J(AL)R(C) 48
Table 3.27: MIPS16e RR Encoding of the ry Field when funct=CNVT 48
Trang 9Chapter 1
About This Book
The MIPS32® Architecture for Programmers Volume IV-a: The MIPS16e™ Application-Specific Extension to theMIPS32® Architecture comes as a multi-volume set
• Volume I describes conventions used throughout the document set, and provides an introduction to the MIPS32®Architecture
• Volume II provides detailed descriptions of each instruction in the MIPS32® instruction set
• Volume III describes the MIPS32® Privileged Resource Architecture which defines and governs the behavior ofthe privileged resources included in a MIPS32® processor implementation
• Volume IV-a describes the MIPS16e™ Application-Specific Extension to the MIPS32® Architecture
• Volume IV-b describes the MDMX™ Application-Specific Extension to the MIPS32® Architecture and is notapplicable to the MIPS32® document set
• Volume IV-c describes the MIPS-3D® Application-Specific Extension to the MIPS32® Architecture
• Volume IV-d describes the SmartMIPS®Application-Specific Extension to the MIPS32® Architecture
1.1 Typographical Conventions
This section describes the use of italic, bold andcourier fonts in this book
1.1.1 Italic Text
• is used for emphasis
• is used for bits, fields, registers, that are important from a software perspective (for instance, address bits used by software, and programmable fields and registers), and various floating point instruction formats, such as S , D,
and PS
• is used for the memory access types, such as cached and uncached
1.1.2 Bold Text
• represents a term that is being defined
• is used for bits and fields that are important from a hardware perspective (for instance, register bits, which are
not programmable but accessible only to hardware)
Trang 10• is used for ranges of numbers; the range is indicated by an ellipsis For instance, 5 1 indicates numbers 5 through
1.2 UNPREDICTABLE and UNDEFINED
The terms UNPREDICTABLE and UNDEFINED are used throughout this book to describe the behavior of the cessor in certain cases UNDEFINED behavior or operations can occur only as the result of executing instructions in
pro-a privileged mode (i.e., in Kernel Mode or Debug Mode, or with the CP0 uspro-able bit set in the Stpro-atus register)
Unpriv-ileged software can never cause UNDEFINED behavior or operations Conversely, both privUnpriv-ileged and unprivUnpriv-ileged software can cause UNPREDICTABLE results or operations.
1.2.1 UNPREDICTABLE
UNPREDICTABLE results may vary from processor implementation to implementation, instruction to instruction,
or as a function of time on the same implementation or instruction Software can never depend on results that are
UNPREDICTABLE UNPREDICTABLE operations may cause a result to be generated or not If a result is ated, it is UNPREDICTABLE UNPREDICTABLE operations may cause arbitrary exceptions.
gener-UNPREDICTABLE results or operations have several implementation restrictions:
• Implementations of operations generating UNPREDICTABLE results must not depend on any data source
(memory or internal state) which is inaccessible in the current processor mode
• UNPREDICTABLE operations must not read, write, or modify the contents of memory or internal state which
is inaccessible in the current processor mode For example, UNPREDICTABLE operations executed in user
mode must not access memory or internal state that is only accessible in Kernel Mode or Debug Mode or inanother process
• UNPREDICTABLE operations must not halt or hang the processor
1.2.2 UNDEFINED
UNDEFINED operations or behavior may vary from processor implementation to implementation, instruction to instruction, or as a function of time on the same implementation or instruction UNDEFINED operations or behavior may vary from nothing to creating an environment in which execution can no longer continue UNDEFINED opera-
tions or behavior may cause data loss
UNDEFINED operations or behavior has one implementation restriction:
• UNDEFINED operations or behavior must not cause the processor to hang (that is, enter a state from which
there is no exit other than powering down the processor) The assertion of any of the reset signals must restore theprocessor to an operational state
Trang 111.3 Special Symbols in Pseudocode Notation
1.2.3 UNSTABLE
UNSTABLE results or values may vary as a function of time on the same implementation or instruction Unlike UNPREDICTABLE values, software may depend on the fact that a sampling of an UNSTABLE value results in a
legal transient value that was correct at some point in time prior to the sampling
UNSTABLE values have one implementation restriction:
• Implementations of operations generating UNSTABLE results must not depend on any data source (memory or
internal state) which is inaccessible in the current processor mode
1.3 Special Symbols in Pseudocode Notation
In this book, algorithmic descriptions of an operation are described as pseudocode in a high-level language notationresembling Pascal Special symbols used in the pseudocode notation are listed inTable 1.1
Table 1.1 Symbols Used in Instruction Operation Statements
=, ≠ Tests for equality and inequality
|| Bit string concatenation
xy A y-bit string formed by y copies of the single-bit value x
b#n A constant value n in base b For instance 10#100 represents the decimal value 100, 2#100 represents the
binary value 100 (decimal 4), and 16#100 represents the hexadecimal value 100 (decimal 256) If the "b#" prefix is omitted, the default base is 10.
0bn A constant value n in base 2 For instance 0b100 represents the binary value 100 (decimal 4).
0xn A constant value n in base 16 For instance 0x100 represents the hexadecimal value 100 (decimal 256).
xy z Selection of bits y through z of bit string x Little-endian bit notation (rightmost bit is 0) is used If y is less
than z, this expression is an empty (zero length) bit string.
+, − 2’s complement or floating point arithmetic: addition, subtraction
*, × 2’s complement or floating point multiplication (both used for either)
div 2’s complement integer division
mod 2’s complement modulo
/ Floating point division
< 2’s complement less-than comparison
> 2’s complement greater-than comparison
≤ 2’s complement less-than or equal comparison
≥ 2’s complement greater-than or equal comparison
nor Bitwise logical NOR
xor Bitwise logical XOR
and Bitwise logical AND
or Bitwise logical OR
Trang 12GPRLEN The length in bits (32 or 64) of the CPU general-purpose registers
GPR[x] CPU general-purpose register x The content of GPR[0] is always zero In Release 2 of the Architecture,
GPR[x] is a short-hand notation forSGPR[ SRSCtl CSS , x].
SGPR[s,x] In Release 2 of the Architecture, multiple copies of the CPU general-purpose registers may be implemented.
SGPR[s,x] refers to GPR set s, register x.
FPR[x] Floating Point operand register x
FCC[CC] Floating Point condition code CC FCC[0] has the same value as COC[1].
FPR[x] Floating Point (Coprocessor unit 1), general register x
CPR[z,x,s] Coprocessor unit z, general register x, select s
CP2CPR[x] Coprocessor unit 2, general registerx
CCR[z,x] Coprocessor unit z, control register x
CP2CCR[x] Coprocessor unit 2, control registerx
COC[z] Coprocessor unit z condition signal
Xlat[x] Translation of the MIPS16e GPR number x into the corresponding 32-bit GPR number
BigEndianMem Endian mode as configured at chip reset (0 →Little-Endian, 1 → Big-Endian) Specifies the endianness of the
memory interface (see LoadMemory and StoreMemory pseudocode function descriptions), and the ness of Kernel and Supervisor mode execution.
endian-BigEndianCPU The endianness for load and store instructions (0 → Little-Endian, 1 → Big-Endian) In User mode, this
endi-anness may be switched by setting the RE bit in the Status register Thus, BigEndianCPU may be computed
as (BigEndianMem XOR ReverseEndian).
ReverseEndian Signal to reverse the endianness of load and store instructions This feature is available in User mode only,
and is implemented by setting the RE bit of the Status register Thus, ReverseEndian may be computed as
(SRRE and User mode).
LLbit Bit of virtual state used to specify operation for instructions that provide atomic read-modify-write LLbit is
set when a linked load occurs and is tested by the conditional store It is cleared, during other CPU operation, when a store to the location would no longer be atomic In particular, it is cleared by exception return instruc- tions.
I:,
I+n:,
I-n:
This occurs as a prefix to Operation description lines and functions as a label It indicates the instruction time
during which the pseudocode appears to “execute.” Unless otherwise indicated, all effects of the current instruction appear to occur during the instruction time of the current instruction No label is equivalent to a
time label of I Sometimes effects of an instruction appear to occur either earlier or later — that is, during the
instruction time of another instruction When this happens, the instruction operation is written in sections
labeled with the instruction time, relative to the current instruction I, in which the effect of that pseudocode
appears to occur For example, an instruction may have a result that is not available until after the next instruction Such an instruction has the portion of the instruction operation description that writes the result
register in a section labeled I + 1.
The effect of pseudocode statements for the current instruction labelled I + 1 appears to occur “at the same
time” as the effect of pseudocode statements labeled I for the following instruction Within one pseudocode
sequence, the effects of the statements take place in order However, between sequences of statements for ferent instructions that occur “at the same time,” there is no defined order Programs must not depend on a particular order of evaluation between such sections.
dif-Table 1.1 Symbols Used in Instruction Operation Statements (Continued)
Trang 131.4 For More Information
1.4 For More Information
Various MIPS RISC processor manuals and additional information about MIPS products can be found at the MIPSURL:
http://www.mips.com
Comments or questions on the MIPS32® Architecture or this document should be directed to
PC The Program Counter value During the instruction time of an instruction, this is the address of the
instruc-tion word The address of the instrucinstruc-tion that occurs during the next instrucinstruc-tion time is determined by
assign-ing a value to PC durassign-ing an instruction time If no value is assigned to PC durassign-ing an instruction time by any
pseudocode statement, it is automatically incremented by either 2 (in the case of a 16-bit MIPS16e
instruc-tion) or 4 before the next instruction time A taken branch assigns the target address to the PC during the
instruction time of the instruction in the branch delay slot.
In the MIPS Architecture, the PC value is only visible indirectly, such as when the processor stores the restart address into a GPR on a jump-and-link or branch-and-link instruction, or into a Coprocessor 0 register on an exception The PC value contains a full 32-bit address all of which are significant during a memory refer- ence.
ISA Mode In processors that implement the MIPS16e Application Specific Extension, theISA Modeis a single-bit
reg-ister that determines in which mode the processor is executing, as follows:
In the MIPS Architecture, the ISA Mode value is only visible indirectly, such as when the processor stores a combined value of the upper bits of PC and the ISA Mode into a GPR on a jump-and-link or branch-and-link instruction, or into a Coprocessor 0 register on an exception.
PABITS The number of physical address bits implemented is represented by the symbol PABITS As such, if 36
phys-ical address bits were implemented, the size of the physphys-ical address space would be 2PABITS = 236 bytes FP32RegistersMode Indicates whether the FPU has 32-bit or 64-bit floating point registers (FPRs) In MIPS32, the FPU has 32
32-bit FPRs in which 64-bit data types are stored in even-odd pairs of FPRs In MIPS64, the FPU has 32 64-bit FPRs in which 64-bit data types are stored in any FPR.
In MIPS32 implementations, FP32RegistersMode is always a 0 MIPS64 implementations have a
compati-bility mode in which the processor references the FPRs as if it were a MIPS32 implementation In such a
case FP32RegisterMode is computed from the FR bit in the Status register If this bit is a 0, the processor
operates as if it had 32 32-bit FPRs If this bit is a 1, the processor operates with 32 64-bit FPRs.
The value of FP32RegistersMode is computed from the FR bit in the Status register.
InstructionInBranchDe-laySlot
Indicates whether the instruction at the Program Counter address was executed in the delay slot of a branch
or jump This condition reflects the dynamic state of the instruction, not the static state That is, the value is
false if a branch or jump occurs to an instruction whose PC immediately follows a branch or jump, but which
is not executed in the delay slot of a branch or jump.
SignalException(excep-tion, argument)
Causes an exception to be signaled, using the exception parameter as the type of exception and the argument parameter as an exception-specific argument) Control does not return from this pseudocode function—the exception is signaled at the point of the call.
Table 1.1 Symbols Used in Instruction Operation Statements (Continued)
0 The processor is executing 32-bit MIPS instructions
1 The processor is executing MIIPS16e instructions
Trang 14MIPS Architecture Group
MIPS Technologies, Inc
1225 Charleston Road
Mountain View, CA 94043
or via E-mail toarchitecture@mips.com
Trang 15Chapter 2
Guide to the Instruction Set
This chapter provides a detailed guide to understanding the instruction descriptions, which are listed in alphabeticalorder in the tables at the beginning of the next chapter
2.1 Understanding the Instruction Fields
Figure 2.1 shows an example instruction Following the figure are descriptions of the fields listed below:
• “Instruction Fields” on page 17
• “Instruction Descriptive Name and Mnemonic” on page 17
• “Format Field” on page 17
• “Purpose Field” on page 18
• “Description Field” on page 18
• “Restrictions Field” on page 18
• “Operation Field” on page 19
• “Exceptions Field” on page 19
• “Programming Notes and Implementation Notes Fields” on page 20
Trang 16Figure 2.1 Example of Instruction Description
EXAMPLE 000000
Format: EXAMPLE fd,rs,rt MIPS32
Purpose: Example Instruction Name
To execute an EXAMPLE op
instruc-Operation:
/* This section describes the operation of an instruction in */ /* a high-level pseudo-language It is precise in ways that */ /* the Description section is not, but is also missing */ /* information that is hard to express in pseudocode */ temp ← GPR[rs] exampleop GPR[rt]
Like Programming Notes, except for processor implementors
Instruction Mnemonic and
Descriptive Name
Instruction encoding
constant and variable field
names and values
Architecture level at which
instruction was defined/redefined
Assembler format(s) for each
instruction can cause
Notes for programmers
Notes for implementors
Trang 172.1 Understanding the Instruction Fields
• Fields that contain zeros but are not named are unused fields that are required to be zero (bits 10:6 inFigure 2.2)
If such fields are set to non-zero values, the operation of the processor is UNPREDICTABLE.
Figure 2.2 Example of Instruction Fields
2.1.2 Instruction Descriptive Name and Mnemonic
The instruction descriptive name and mnemonic are printed as page headings for each instruction, as shown inFigure2.3
Figure 2.3 Example of Instruction Descriptive Name and Mnemonic
2.1.3 Format Field
The assembler formats for the instruction and the architecture level at which the instruction was originally defined are
given in the Format field If the instruction definition was later extended, the architecture levels at which it was
extended and the assembler formats for the extended definition are shown in their order of extension (for an example,seeC.cond.fmt) The MIPS architecture levels are inclusive; higher architecture levels include all instructions in pre-vious levels Extensions to instructions are backwards compatible The original assembler formats are valid for theextended architecture
Figure 2.4 Example of Instruction Format
The assembler format is shown with literal parts of the assembler instruction printed in uppercase characters Thevariable parts, the operands, are shown as the lowercase names of the appropriate fields The architectural level atwhich the instruction was first defined, for example “MIPS32” is shown at the right side of the page
31 26 25 21 20 16 15 11 10 6 5 0
SPECIAL
0 00000
ADD 100000
Format: ADD fd,rs,rt MIPS32
Trang 18There can be more than one assembler format for each architecture level Floating point operations on formatted data
show an assembly format with the actual assembler mnemonic for each valid value of the fmt field For example, the
ADD.fmt instruction lists both ADD.S and ADD.D
The assembler format lines sometimes include parenthetical comments to help explain variations in the formats (onceagain, seeC.cond.fmt) These comments are not a part of the assembler format
2.1.4 Purpose Field
The Purpose field gives a short description of the use of the instruction.
Figure 2.5 Example of Instruction Purpose
2.1.5 Description Field
If a one-line symbolic description of the instruction is feasible, it appears immediately to the right of the Description
heading The main purpose is to show how fields in the instruction are used in the arithmetic or logical operation
Figure 2.6 Example of Instruction Description
The body of the section is a description of the operation of the instruction in text, tables, and figures This description
complements the high-level language description in the Operation section.
This section uses acronyms for register descriptions “GPR rt” is CPU general-purpose register specified by the instruction field rt “FPR fs” is the floating point operand register specified by the instruction field fs “CP1 register
fd” is the coprocessor 1 general register specified by the instruction field fd “FCSR” is the floating point Control /Status register
2.1.6 Restrictions Field
The Restrictions field documents any possible restrictions that may affect the instruction Most restrictions fall into
one of the following six categories:
• Valid values for instruction fields (for example, see floating pointADD.fmt)
• ALIGNMENT requirements for memory addresses (for example, seeLW)
• Valid values of operands (for example, seeALNV.PS)
Purpose: Add Word
To add 32-bit integers If an overflow occurs, then trap
Trang 192.1 Understanding the Instruction Fields
• Valid operand formats (for example, see floating pointADD.fmt)
• Order of instructions necessary to guarantee correct execution These ordering constraints avoid pipeline hazardsfor which some processors do not have hardware interlocks (for example, seeMUL)
• Valid memory access types (for example, seeLL/SC)
Figure 2.7 Example of Instruction Restrictions
2.1.7 Operation Field
The Operation field describes the operation of the instruction as pseudocode in a high-level language notation bling Pascal This formal description complements the Description section; it is not complete in itself because many
resem-of the restrictions are either difficult to include in the pseudocode or are omitted for legibility
Figure 2.8 Example of Instruction Operation
See2.2 “Operation Section Notation and Functions” on page 20 for more information on the formal notation usedhere
2.1.8 Exceptions Field
The Exceptions field lists the exceptions that can be caused by Operation of the instruction It omits exceptions that
can be caused by the instruction fetch, for instance, TLB Refill, and also omits exceptions that can be caused by chronous external events such as an Interrupt Although a Bus Error exception may be caused by the operation of aload or store instruction, this section does not list Bus Error for load and store instructions because the relationshipbetween load and store instructions and external error indications, like Bus Error, are dependent upon the implemen-tation
asyn-Figure 2.9 Example of Instruction Exception
An instruction may cause implementation-dependent exceptions that are not present in the Exceptions section.
GPR[rd] ← temp endif
Exceptions:
Integer Overflow
Trang 202.1.9 Programming Notes and Implementation Notes Fields
The Notes sections contain material that is useful for programmers and implementors, respectively, but that is not
nec-essary to describe the instruction and does not belong in the description sections
Figure 2.10 Example of Instruction Programming Notes
2.2 Operation Section Notation and Functions
In an instruction description, the Operation section uses a high-level language notation to describe the operation
per-formed by each instruction Special symbols used in the pseudocode are described in the previous chapter Specificpseudocode functions are described below
This section presents information about the following topics:
• “Instruction Execution Ordering” on page 20
• “Pseudocode Functions” on page 20
2.2.1 Instruction Execution Ordering
Each of the high-level language statements in the Operations section are executed sequentially (except as constrained
by conditional and loop constructs)
2.2.2 Pseudocode Functions
There are several functions used in the pseudocode descriptions These are used either to make the pseudocode morereadable, to abstract implementation-specific behavior, or both These functions are defined in this section, andinclude the following:
• “Coprocessor General Register Access Functions” on page 20
• “Memory Operation Functions” on page 22
• “Floating Point Functions” on page 25
• “Miscellaneous Functions” on page 28
2.2.2.1 Coprocessor General Register Access Functions
Defined coprocessors, except for CP0, have instructions to exchange words and doublewords between coprocessorgeneral registers and the rest of the system What a coprocessor does with a word or doubleword supplied to it andhow a coprocessor supplies a word or doubleword is defined by the coprocessor itself This behavior is abstracted intothe functions described in this section
Programming Notes:
ADDU performs the same arithmetic operation but does not trap on overflow
Trang 212.2 Operation Section Notation and Functions
COP_LW
The COP_LW function defines the action taken by coprocessor z when supplied with a word from memory during aload word operation The action is coprocessor-specific The typical action would be to store the contents of mem-word in coprocessor general registerrt
Figure 2.11 COP_LW Pseudocode Function
COP_LW (z, rt, memword)
z: The coprocessor unit number
rt: Coprocessor general register specifier memword: A 32-bit word value supplied to the coprocessor
Figure 2.12 COP_LD Pseudocode Function
COP_LD (z, rt, memdouble)
z: The coprocessor unit number
rt: Coprocessor general register specifier memdouble: 64-bit doubleword value supplied to the coprocessor.
/* Coprocessor-dependent action */
endfunction COP_LD
COP_SW
The COP_SW function defines the action taken by coprocessor z to supply a word of data during a store word
opera-tion The action is coprocessor-specific The typical action would be to supply the contents of the low-order word incoprocessor general registerrt
Figure 2.13 COP_SW Pseudocode Function
dataword ← COP_SW (z, rt)
z: The coprocessor unit number
rt: Coprocessor general register specifier dataword: 32-bit word value
/* Coprocessor-dependent action */
endfunction COP_SW
COP_SD
The COP_SD function defines the action taken by coprocessor z to supply a doubleword of data during a store
dou-bleword operation The action is coprocessor-specific The typical action would be to supply the contents of thelow-order doubleword in coprocessor general registerrt
Trang 22Figure 2.14 COP_SD Pseudocode Function
datadouble ← COP_SD (z, rt)
z: The coprocessor unit number
rt: Coprocessor general register specifier datadouble: 64-bit doubleword value
/* Coprocessor-dependent action */
endfunction COP_SD
CoprocessorOperation
The CoprocessorOperation function performs the specified Coprocessor operation
Figure 2.15 CoprocessorOperation Pseudocode Function
CoprocessorOperation (z, cop_fun)
/* z: Coprocessor unit number */
/* cop_fun: Coprocessor function from function field of instruction */
/* Transmit the cop_fun value to coprocessor z */
endfunction CoprocessorOperation
2.2.2.2 Memory Operation Functions
Regardless of byte ordering (big- or little-endian), the address of a halfword, word, or doubleword is the smallest byteaddress of the bytes that form the object For big-endian ordering this is the most-significant byte; for a little-endianordering this is the least-significant byte
In the Operation pseudocode for load and store operations, the following functions summarize the handling of virtual
addresses and the access of physical memory The size of the data item to be loaded or stored is passed in the
AccessLength field The valid constant names and values are shown inTable 2.1 The bytes within the addressed unit
of memory (word for 32-bit processors or doubleword for 64-bit processors) that are used can be determined directly
from the AccessLength and the two or three low-order bits of the address.
virtual address If the virtual address is in one of the mapped address spaces then the TLB or fixed mapping MMUdetermines the physical address and access type; if the required translation is not present in the TLB or the desiredaccess is not permitted, the function fails and an exception is taken
Figure 2.16 AddressTranslation Pseudocode Function
(pAddr, CCA) ← AddressTranslation (vAddr, IorD, LorS)
/* pAddr: physical address */
/* CCA: Cacheability&Coherency Attribute,the method used to access caches*/
Trang 232.2 Operation Section Notation and Functions
/* and memory and resolve the reference */
/* vAddr: virtual address */
/* IorD: Indicates whether access is for INSTRUCTION or DATA */
/* LorS: Indicates whether access is for LOAD or STORE */
/* See the address translation description for the appropriate MMU */
/* type in Volume III of this book for the exact translation mechanism */
endfunction AddressTranslation
LoadMemory
The LoadMemory function loads a value from memory
This action uses cache and main memory as specified in both the Cacheability and Coherency Attribute (CCA) and the access (IorD) to find the contents of AccessLength memory bytes, starting at physical location pAddr The data is returned in a fixed-width naturally aligned memory element (MemElem) The low-order 2 (or 3) bits of the address and the AccessLength indicate which of the bytes within MemElem need to be passed to the processor If the memory access type of the reference is uncached, only the referenced bytes are read from memory and marked as valid within the memory element If the access type is cached but the data is not present in cache, an implementation-specific size and alignment block of memory is read and loaded into the cache to satisfy a load reference At a minimum, this
block is the entire memory element
Figure 2.17 LoadMemory Pseudocode Function
MemElem ← LoadMemory (CCA, AccessLength, pAddr, vAddr, IorD)
/* MemElem: Data is returned in a fixed width with a natural alignment The */ /* width is the same size as the CPU general-purpose register, */ /* 32 or 64 bits, aligned on a 32- or 64-bit boundary, */
/* CCA: Cacheability&CoherencyAttribute=method used to access caches */
/* AccessLength: Length, in bytes, of access */
/* pAddr: physical address */
/* vAddr: virtual address */
/* IorD: Indicates whether access is for Instructions or Data */
endfunction LoadMemory
StoreMemory
The StoreMemory function stores a value to memory
The specified data is stored into the physical location pAddr using the memory hierarchy (data caches and main ory) as specified by the Cacheability and Coherency Attribute (CCA) The MemElem contains the data for an aligned,
mem-fixed-width memory element (a word for 32-bit processors, a doubleword for 64-bit processors), though only the
bytes that are actually stored to memory need be valid The low-order two (or three) bits of pAddr and the
AccessLen-gth field indicate which of the bytes within the MemElem data should be stored; only these bytes in memory will
actu-ally be changed
Figure 2.18 StoreMemory Pseudocode Function
StoreMemory (CCA, AccessLength, MemElem, pAddr, vAddr)
Trang 24/* CCA: Cacheability&Coherency Attribute, the method used to access */ /* caches and memory and resolve the reference */
/* AccessLength: Length, in bytes, of access */
/* MemElem: Data in the width and alignment of a memory element */
/* The width is the same size as the CPU general */
/* aligned on a 4- or 8-byte boundary For a */
/* partial-memory-element store, only the bytes that will be*/
/* pAddr: physical address */
/* vAddr: virtual address */
endfunction StoreMemory
Prefetch
The Prefetch function prefetches data from memory
Prefetch is an advisory instruction for which an implementation-specific action is taken The action taken mayincrease performance but must not change the meaning of the program or alter architecturally visible state
Figure 2.19 Prefetch Pseudocode Function
Prefetch (CCA, pAddr, vAddr, DATA, hint)
/* CCA: Cacheability&Coherency Attribute, the method used to access */
/* caches and memory and resolve the reference */
/* pAddr: physical address */
/* vAddr: virtual address */
/* DATA: Indicates that access is for DATA */
/* hint: hint that indicates the possible use of the data */
endfunction Prefetch
Table 2.1 lists the data access lengths and their labels for loads and stores
SyncOperation
The SyncOperation function orders loads and stores to synchronize shared memory
Table 2.1 AccessLength Specifications for Loads/Stores
DOUBLEWORD 7 8 bytes (64 bits) SEPTIBYTE 6 7 bytes (56 bits) SEXTIBYTE 5 6 bytes (48 bits) QUINTIBYTE 4 5 bytes (40 bits)
TRIPLEBYTE 2 3 bytes (24 bits)
Trang 252.2 Operation Section Notation and Functions
This action makes the effects of the synchronizable loads and stores indicated by stype occur in the same order for all
processors
Figure 2.20 SyncOperation Pseudocode Function
SyncOperation(stype)
/* stype: Type of load/store ordering to perform */
/* Perform implementation-dependent operation to complete the */
/* required synchronization operation */
endfunction SyncOperation
2.2.2.3 Floating Point Functions
The pseudocode shown in below specifies how the unformatted contents loaded or moved to CP1 registers are preted to form a formatted value If an FPR contains a value in some format, rather than unformatted contents from aload (uninterpreted), it is valid to interpret the value in that format (but not to interpret it in a different format)
inter-ValueFPR
The ValueFPR function returns a formatted value from the floating point registers
Figure 2.21 ValueFPR Pseudocode Function
/* The UNINTERPRETED values are used to indicate that the datatype */
/* is not known as, for example, in SWC1 and SDC1 */
else valueFPR ← FPR[fpr+1]31 0 || FPR[fpr]31 0endif
else valueFPR ← FPR[fpr]
endif
L, PS:
if (FP32RegistersMode = 0) then valueFPR ← UNPREDICTABLE
Trang 26else valueFPR ← FPR[fpr]
endif DEFAULT:
valueFPR ← UNPREDICTABLE
endcase endfunction ValueFPR
The pseudocode shown below specifies the way a binary encoding representing a formatted value is stored into CP1registers by a computational or move operation This binary representation is visible to store or move-from instruc-tions Once an FPR receives a value from the StoreFPR(), it is not valid to interpret the value with ValueFPR() in adifferent format
/* value: The formattted value to be stored into the FPR */
/* The UNINTERPRETED values are used to indicate that the datatype */
/* is not known as, for example, in LWC1 and LDC1 */
else FPR[fpr] ← value endif
L, PS:
if (FP32RegistersMode = 0) then
UNPREDICTABLE
else FPR[fpr] ← value endif
endcase
Trang 272.2 Operation Section Notation and Functions
if ( (FCSR17 = 1) or
((FCSR16 12 and FCSR11 7) ≠ 0)) ) then SignalException(FloatingPointException) endif
endfunction CheckFPException
FPConditionCode
The FPConditionCode function returns the value of a specific floating point condition code
Figure 2.24 FPConditionCode Pseudocode Function
tf ←FPConditionCode(cc)
/* tf: The value of the specified condition code */
/* cc: The Condition code number in the range 0 7 */
if cc = 0 then FPConditionCode ← FCSR 23
else FPConditionCode ← FCSR 24+cc
endif endfunction FPConditionCode
SetFPConditionCode
The SetFPConditionCode function writes a new value to a specific floating point condition code
Figure 2.25 SetFPConditionCode Pseudocode Function
SetFPConditionCode(cc)
if cc = 0 then FCSR ← FCSR 31 24 || tf || FCSR22 0else
FCSR ← FCSR 31 25+cc || tf || FCSR23+cc 0endif
endfunction SetFPConditionCode
Trang 282.2.2.4 Miscellaneous Functions
This section lists miscellaneous functions not covered in previous sections
SignalException
The SignalException function signals an exception condition
This action results in an exception that aborts the instruction The instruction operation pseudocode never sees areturn from this function call
Figure 2.26 SignalException Pseudocode Function
SignalException(Exception, argument)
/* Exception: The exception condition that exists */
/* argument: A exception-dependent argument, if any */
The NullifyCurrentInstruction function nullifies the current instruction
The instruction is aborted, inhibiting not only the functional effect of the instruction, but also inhibiting all exceptionsdetected during fetch, decode, or execution of the instruction in question For branch-likely instructions, nullificationkills the instruction in the delay slot of the branch likely instruction
Trang 292.3 Op and Function Subfield Notation
Figure 2.29 NullifyCurrentInstruction PseudoCode Function
NullifyCurrentInstruction()
endfunction NullifyCurrentInstruction
JumpDelaySlot
The JumpDelaySlot function is used in the pseudocode for the PC-relative instructions in the MIPS16e ASE The
function returns TRUE if the instruction at vAddr is executed in a jump delay slot A jump delay slot always
immedi-ately follows a JR, JAL, JALR, or JALX instruction
Figure 2.30 JumpDelaySlot Pseudocode Function
JumpDelaySlot(vAddr)
/* vAddr:Virtual address */
endfunction JumpDelaySlot
PolyMult
The PolyMult function multiplies two binary polynomial coefficients
Figure 2.31 PolyMult Pseudocode Function
PolyMult(x, y)
temp ← 0 for i in 0 31
if xi = 1 then temp ← temp xor (y (31-i) 0 || 0i) endif
endfor PolyMult ← temp endfunction PolyMult
2.3 Op and Function Subfield Notation
In some instructions, the instruction subfields op and function can have constant 5- or 6-bit values When reference is
made to these instructions, uppercase mnemonics are used For instance, in the floating point ADD instruction,
op=COP1 and function=ADD In other cases, a single field has both fixed and variable subfields, so the name
con-tains both upper- and lowercase characters
2.4 FPU Instructions
In the detailed description of each FPU instruction, all variable subfields in an instruction format (such as fs, ft,
imme-diate, and so on) are shown in lowercase The instruction name (such as ADD, SUB, and so on) is shown in
upper-case
For the sake of clarity, an alias is sometimes used for a variable subfield in the formats of specific instructions For
example, rs=base in the format for load and store instructions Such an alias is always lowercase since it refers to a
variable subfield
Trang 30Bit encodings for mnemonics are given in Volume I, in the chapters describing the CPU, FPU, MDMX, and MIPS16einstructions.
See“Op and Function Subfield Notation” on page 29 for a description of the op and function subfields
Trang 313.1 Base Architecture Requirements
The MIPS16e ASE requires the following base architecture support:
• The MIPS32 or MIPS64 Architecture: The MIPS16e ASE requires a compliant implementation of the MIPS32
or MIPS64 Architecture
3.2 Software Detection of the ASE
Software may determine if the MIPS16e ASE is implemented by checking the state of the CA bit in the Config1 CP0
register
3.3 Compliance and Subsetting
There are no instruction subsets of the MIPS16e ASE to the MIPS64 Architecture — all MIPS16e instructions must
be implemented Specifically, this means that the original MIPS16 ASE is not an allowable subset of the MIPS16eASE For the MIPS16e ASE to the MIPS32 Architecture, the instructions which require a 64-bit processor are notimplemented and execution of such an instruction must cause a Reserved Instruction exception
3.4 MIPS16e Overview
The MIPS16e ASE allows embedded designs to substantially reduce system cost by reducing overall memoryrequirements The MIPS16e ASE is compatible with any combination of the MIPS32 or MIPS64 Architectures, andexisting MIPS binaries can be run without modification on any embedded processor implementing the MIPS16eASE
The MIPS16e ASE must be implemented as part of a MIPS based host processor that includes an implementation ofthe MIPS Privileged Resource Architecture, and the other components in a typical MIPS based system
This volume describes only the MIPS16e ASE, and does not include information about any specific hardware mentation such as processor-specific details, because these details may vary with implementation For this informa-tion, please refer to the specific processor’s user manual
imple-This chapter presents specific information about the following topics:
Trang 32• “MIPS16e ASE Features” on page 32
• “MIPS16e Register Set” on page 32
• “MIPS16e ISA Modes” on page 34
• “JALX, JR, JR.HB, JALR and JALR.HB Operations in MIPS16e and MIPS32 Mode” on page 35
• “MIPS16e Instruction Summaries” on page 36
• “MIPS16e PC-Relative Instructions” on page 38
• “MIPS16e Extensible Instructions” on page 39
• “MIPS16e Implementation-Definable Macro Instructions” on page 40
• “MIPS16e Jump and Branch Instructions” on page 41
• “MIPS16e Instruction Formats” on page 41
• “Instruction Bit Encoding” on page 45
• “MIPS16e Instruction Stream Organization and Endianness” on page 48
• “MIPS16e Instruction Fetch Restrictions” on page 49
3.5 MIPS16e ASE Features
The MIPS16e ASE includes the following features:
• allows MIPS16e instructions to be intermixed with existing MIPS instruction binaries
• is compatible with the MIPS32 and MIPS64 instruction sets
• allows switching between MIPS16e and 32-bit MIPS Mode
• supports 8, 16, 32, and 64-bit data types (64-bit only in conjunction with MIPS64)
• defines eight general-purpose registers, as well as a number of special-purpose registers
• defines special instructions to increase code density (Extend, PC-relative instructions)
The MIPS16e ASE contains some instructions that are available on MIPS64 host processors only These instructionsmust cause a Reserved Instruction exception on 32-bit processors, or on 64-bit processors on which 64-bit operationshave not been enabled
3.6 MIPS16e Register Set
The MIPS16e register set is listed inTable 3.1andTable 3.2 This register set is a true subset of the register set able in 32-bit mode; the MIPS16e ASE can directly access 8 of the 32 registers available in 32-bit mode
Trang 33avail-3.6 MIPS16e Register Set
In addition to the eight general-purpose registers, 0-7, listed inTable 3.1, specific instructions in the MIPS16e ASE
reference the stack pointer register (sp), the return address register (ra), the condition code register (t8), and the gram counter (PC) Of these,Table 3.1lists sp, ra, and t8, andTable 3.2lists the MIPS16e special-purpose registers,
pro-including PC.
The MIPS16e ASE also contains two move instructions that provide access to all 32 general-purpose registers
Table 3.1 MIPS16e General-Purpose Registers
MIPS16e Register Encoding 1
1 “0-7” correspond to the register’s MIPS16e binary encoding and show how that encoding relates to the MIPS registers “0-7” never refer to the registers, except within the binary MIPS16e instructions From the assembler, only the MIPS names ($16, $17, $2, etc.) or the symbolic names (s0, s1, v0, etc.) refer to the registers For example, to access register num- ber 17 in the register file, the programmer references $17 or s1, even though the MIPS16e binary encoding for this register is 001.
32-Bit MIPS Register Encoding 2
2 General registers not shown in the above table are not accessible through the MIPS16e instruction set, except by using the Move instructions The MIPS16e Move instructions can access all 32 general-purpose registers.
Symbolic Name (From
implicitly referenced by the BTEQZ, BTNEZ, CMP, CMPI, SLT, SLTU, SLTI, and SLTIU instructions
Table 3.2 MIPS16e Special-Purpose Registers
PC Program counter The PC-relative Add and Load
instruc-tions can access this register as an operand.
HI Contains high-order word of multiply or divide result.
Trang 343.7 MIPS16e ISA Modes
This section describes the following:
• the ISA modes available in the architecture,page 34
• the purpose of the ISA Mode field,page 34
• how to switch between 32-bit MIPS and MIPS16e modes,page 34
• the role of the jump instructions when switching modes,page 35
3.7.1 Modes Available in the MIPS16e Architecture
There are two ISA modes defined in the MIPS16e Architecture, as follows:
• MIPS 32-bit mode (32-bit instructions)
• MIPS16e mode (16-bit instructions)
3.7.2 Defining the ISA Mode Field
The ISA Mode bit controls the type of code that is executed, as follows:
In MIPS 32-bit mode and MIPS16e mode, the JALX, JR, JALR, JALRC, and JRC instructions can change the ISA
Mode bit, as described inSection 3.7.4, "Using MIPS16e Jump Instructions to Switch Modes"
3.7.3 Switching Between Modes When an Exception Occurs
When an exception occurs (including a Reset exception), the ISA Mode bit is cleared so that exceptions are handled
by 32-bit code
LO Contains low-order word of multiply or divide result.
Table 3.3 ISA Mode Bit Encodings
0b0 MIPS 32-bit mode In this mode, the processor executes
32-bit MIPS instructions.
0b1 MIPS16e mode In this mode, the processor executes
MIPS16e instructions.
Table 3.2 MIPS16e Special-Purpose Registers
Trang 353.8 JALX, JR, JR.HB, JALR and JALR.HB Operations in MIPS16e and MIPS32 Mode
The ISA Mode in which the processor was running at the time that the exception occurred is visible to software as bit
0 of the Coprocessor 0 register in which the restart address is stored (EPC,ErrorEPC, orDEPC) See the tion of these instructions in Volume III for a complete description of this process
descrip-After the processor switches to 32-bit mode following a Reset exception, the processor starts execution at the 32-bitmode Reset exception vector
3.7.4 Using MIPS16e Jump Instructions to Switch Modes
The MIPS16e application-specific extension supports procedure calls and returns from both MIPS16e and 32-bitMIPS code to both MIPS16e and 32-bit MIPS code The following instructions are used:
• The JAL instruction supports calls to the same ISA
• The JALX instruction supports calls that change the ISA
• The JALR, JALR.HB and JALRC instructions support calls to either ISA
• The JR, JR.HB and JRC instructions support returns to either ISA
The JAL, JALR, JALR.HB, JALRC, and JALX instructions save the ISA Mode bit in bit 0 of the general register
con-taining the return address The contents of this general register may be used by a future JR, JR.HB, JRC, JALR, orJALRC instruction to return and restore the ISA Mode
The JALX instruction in both modes switches to the other ISA (it changes 0b0→ 0b1 and 0b1 → 0b0)
The JR, JR.HB, JALR and JALR.HB instructions in both modes load the ISA Mode bit from bit 0 of the general
regis-ter holding the target address Bit 0 of the general regisregis-ter is not part of the target address; bit 0 of PC is loaded with a
0 so that no address exceptions can occur
The JRC and JALRC instructions in MIPS16e mode load the ISA Mode bit from bit 0 of the general register holding
the target address Bit 0 of the general register is not part of the target address; bit 0 of PC is loaded with a 0 so that noaddress exceptions can occur
3.8 JALX, JR, JR.HB, JALR and JALR.HB Operations in MIPS16e and
MIPS32 Mode
The behavior of five of the 32-bit MIPS instructions—JALX, JR, JR.HB, JALR, JALR.HB —differs between thoseprocessors that implement MIPS16e and those processors that do not
In processors that implement the MIPS16e ASE, the five instructions behave as follows:
• The JALX instruction executes a JAL and switches to the other mode
• JR, JR.HB, JALR and JALR.HB instructions load the ISA Mode bit from bit 0 of the source register Bit 0 of PC
is loaded with a 0, and no Address exception can occur when bit 0 of the source register is a 1 (MIPS16e mode)
In CPUs that do not implement the MIPS16e ASE, the five instructions behave as follows:
Trang 36• JALX instructions cause a Reserved Instruction exception.
• JR, JR.HB, JALR and JALR.HB instructions cause an Address exception on the target instruction fetch when bit
0 of the source register is a 1
3.9 MIPS16e Instruction Summaries
This section describes the various instruction categories and then summarizes the MIPS16e instructions included ineach category Extensible instructions are also identified
There are six instruction categories:
• Loads and Stores—These instructions move data between memory and the GPRs.
• Save and Restore—These instructions create and tear down stack frames.
• Computational—These instructions perform arithmetic, logical, and shift operations on values in registers.
• Jump and Branch—These instructions change the control flow of a program.
• Special—This category includes the Break and Extend instructions Break transfers control to an exception
han-dler, and Extend enlarges the immediate field of the next instruction.
• Implemention-Definable Macro Instructions—This category includes the capability of defining macros that
are replaced at execution time by a set of 32-bit MIPS instructions, with appropriate parameter substitution.Tables3.4 through3.12 list the MIPS16e instruction set
Table 3.4 MIPS16e Load and Store Instructions
Table 3.5 MIPS16e Save and Restore Instructions
Extensible Instruction?
Implemented Only on MIPS64 Processors?
Extensible Instruction?
Implemented Only on MIPS64 Processors?
RESTORE Restore Registers and Deallocate Stack Frame Yes No
Trang 373.9 MIPS16e Instruction Summaries
Table 3.6 MIPS16e ALU Immediate Instructions
Table 3.7 MIPS16e Arithmetic One, Two or Three Operand Register Instructions
Table 3.8 MIPS16e Special Instructions
Table 3.9 MIPS16e Multiply and Divide Instructions
Extensible Instruction?
Implemented Only on MIPS64 Processors?
Extensible Instruction?
Implemented Only on MIPS64 Processors?
Extensible Instruction?
Implemented Only on MIPS64 Processors?
Extensible Instruction?
Implemented Only on MIPS64 Processors?
Trang 38Table 3.10 MIPS16e Jump and Branch Instructions
Table 3.11 MIPS16e Shift Instructions
Table 3.12 Implementation-Definable Macro Instructions
3.10 MIPS16e PC-Relative Instructions
The MIPS16e ASE provides PC-relative addressing for four instructions, in both extended and non-extended sions The two instructions are listed inTable 3.13
ver-Table 3.13 PC-Relative MIPS16e Instructions
Extensible Instruction?
Implemented Only on MIPS64 Processors?
JAL1
1 The JAL and JALX instructions are not extensible because they are inherently 32-bit instructions.
Extensible Instruction?
Implemented Only on MIPS64 Processors?
Extensible Instruction?
Implemented Only on MIPS64 Processors?
ASMACRO Implementation-Definable Macro Instructions Yes1
1 The Implementation-Definable Macro Instructions are always extended instructions There are no 16-bit
macro instruction
No
Add Immediate Unsigned ADDIU rx, pc, immediate
Trang 393.11 MIPS16e Extensible Instructions
These instructions use the PC value of either the PC-relative instruction itself or the PC value for the precedinginstruction as the base for address calculation
Table 3.14 summarizes the address calculation base used for the various instruction combinations
Table 3.14 PC-Relative Base Used for Address Calculation
The JRC and JALRC instructions do not have delay slots and do not affect the PC-relative base address calculated for
an instruction immediately following the JRC or JALRC
In the descriptive summaries of PC-relative instructions, located in Tables3.13 and3.14, the PC value used as the
basis for calculating the address is referred to as the BasePC value The BasePC equals the Exception Program
Counter (EPC) value associated with the PC-relative instruction.
3.11 MIPS16e Extensible Instructions
This section explains the purpose of an Extend instruction, how to use it, and which MIPS16e instructions are
exten-sible
The Extend instruction allows you to enlarge the immediate field of any MIPS16e instruction whose immediate field
is smaller than the immediate field in the equivalent 32-bit MIPS instruction The Extend instruction is a prefix which
modifies the behavior of the instruction which follows it, and must always immediately precede the instruction whose
immediate field you want to extend Every extended instruction uses 4 bytes in program memory instead of 2 bytes (2
bytes for Extend and 2 bytes for the instruction being extended), and it can cross a word boundary The PC value of anextended instruction is the address of the halfword containing the Extend
For example, the following MIPS16e instruction contains a five-bit immediate.
ADDIU ry, rx, immediate
Unlike most other extended instructions, an extended RESTORE or SAVE instruction provides both a larger framesize adjustment, and the ability to save and restore more registers than the non-extended version
Non-extended PC-relative instruction not in Jump Delay Slot
Address of instruction Extended PC-relative instruction Address of Extend instruction Non-extended PC-relative instruction in JR or JALR
jump delay slot
Address of JR or JALR instruction
Non-extended PC-relative instruction in JAL or JALX jump delay slot
Address of first JAL or JALX word
Trang 40half-Once both halves of an extended instruction have been fetched and the instruction starts flowing down the pipeline,the instruction is treated as a single entity, not as independent instructions This implies that an exception or interruptnever reports an EPC value between the EXTEND and the instruction being extended, and that EJTAG single steptreats an instruction step as the execution of the entire extended instruction, not the components.
There is only one restriction on the location of extensible instructions: They may not be placed in jump delay slots
Doing so causes UNPREDICTABLE results.
Table 3.15 lists the MIPS16e extensible instructions, the size of their immediate, and how much each immediate can
be extended when preceded with an Extend instruction Executing an instruction which is not extensible (those whichare maked No in the “Extensible Instruction?” column ofTable 3.4 throughTable 3.12, including the EXTENDinstruction itself) must cause a Reserved Instruction Exception
Table 3.15 MIPS16e Extensible Instructions
3.12 MIPS16e Implementation-Definable Macro Instructions
Previous revisions of the MIPS16e ASE assumed that most MIPS16e instructions mapped to a single 32-bit MIPSinstruction However, there are several MIPS16e instructions for which there is no corresponding 32-bit MIPS
ADDIU Add Immediate Unsigned 4 (ADDIU ry, rx, imm)
8
15 (ADDIU ry, rx, imm)
16
RESTORE Restore Registers and Deallocate Stack