Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:51

0001 /**
0002  * @file
0003  * @ingroup
0004  * @brief Instruction formats and opcode values for MIPS
0005  */
0006 
0007 /*
0008  * Copyright (c) 1992 The Regents of the University of California.
0009  * All rights reserved.
0010  *
0011  * This code is derived from software contributed to Berkeley by
0012  * Ralph Campbell.
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  * 3. All advertising materials mentioning features or use of this software
0023  *    must display the following acknowledgement:
0024  *  This product includes software developed by the University of
0025  *  California, Berkeley and its contributors.
0026  * 4. Neither the name of the University nor the names of its contributors
0027  *    may be used to endorse or promote products derived from this software
0028  *    without specific prior written permission.
0029  *
0030  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
0031  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0032  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0033  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
0034  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0035  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0036  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0037  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0038  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0039  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0040  * SUCH DAMAGE.
0041  *
0042  * from: @(#)mips_opcode.h  7.1 (Berkeley) 3/19/92
0043  * via: mips_opcode.h,v 1.1 1994/03/10 16:15:10 (algorithmics)
0044  */
0045 
0046 /*
0047  * Define the instruction formats and opcode values for the
0048  * MIPS instruction set.
0049  */
0050 
0051 #ifndef _MIPS_OPCODE_H
0052 #define _MIPS_OPCODE_H
0053 
0054 /**
0055  * @defgroup mips_ops MIPS Opcodes
0056  * @ingroup RTEMSBSPsMIPSShared
0057  * @brief MIPS Instruction Formats and Opcode Values
0058  * @{
0059  */
0060 
0061 /**
0062  * @name Instruction formats
0063  * @{
0064  */
0065 
0066 typedef union {
0067     unsigned word;
0068 
0069 #ifdef MIPSEL
0070     struct {
0071     unsigned imm: 16;
0072     unsigned rt: 5;
0073     unsigned rs: 5;
0074     unsigned op: 6;
0075     } IType;
0076 
0077     struct {
0078     unsigned target: 26;
0079     unsigned op: 6;
0080     } JType;
0081 
0082     struct {
0083     unsigned func: 6;
0084     unsigned shamt: 5;
0085     unsigned rd: 5;
0086     unsigned rt: 5;
0087     unsigned rs: 5;
0088     unsigned op: 6;
0089     } RType;
0090 
0091     struct {
0092     unsigned func: 6;
0093     unsigned fd: 5;
0094     unsigned fs: 5;
0095     unsigned ft: 5;
0096     unsigned fmt: 4;
0097     unsigned : 1;       /* always '1' */
0098     unsigned op: 6;     /* always '0x11' */
0099     } FRType;
0100 #else
0101     struct {
0102     unsigned op: 6;
0103     unsigned rs: 5;
0104     unsigned rt: 5;
0105     unsigned imm: 16;
0106     } IType;
0107 
0108     struct {
0109     unsigned op: 6;
0110     unsigned target: 26;
0111     } JType;
0112 
0113     struct {
0114     unsigned op: 6;
0115     unsigned rs: 5;
0116     unsigned rt: 5;
0117     unsigned rd: 5;
0118     unsigned shamt: 5;
0119     unsigned func: 6;
0120     } RType;
0121 
0122     struct {
0123     unsigned op: 6;     /* always '0x11' */
0124     unsigned : 1;       /* always '1' */
0125     unsigned fmt: 4;
0126     unsigned func: 6;
0127     unsigned ft: 5;
0128     unsigned fs: 5;
0129     unsigned fd: 5;
0130     } FRType;
0131 #endif
0132 } InstFmt;
0133 
0134 /** @} */
0135 
0136 /**
0137  * @name 'op' field values
0138  * @{
0139  */
0140 
0141 #define OP_SPECIAL  000
0142 #define OP_REGIMM   001
0143 #define OP_J        002
0144 #define OP_JAL      003
0145 #define OP_BEQ      004
0146 #define OP_BNE      005
0147 #define OP_BLEZ     006
0148 #define OP_BGTZ     007
0149 
0150 #define OP_ADDI     010
0151 #define OP_ADDIU    011
0152 #define OP_SLTI     012
0153 #define OP_SLTIU    013
0154 #define OP_ANDI     014
0155 #define OP_ORI      015
0156 #define OP_XORI     016
0157 #define OP_LUI      017
0158 
0159 #define OP_COP0     020
0160 #define OP_COP1     021
0161 #define OP_COP2     022
0162 #define OP_BEQL     024
0163 #define OP_BNEL     025
0164 #define OP_BLEZL    026
0165 #define OP_BGTZL    027
0166 
0167 #define OP_DADDI    030
0168 #define OP_DADDIU   031
0169 #define OP_LDL      032
0170 #define OP_LDR      033
0171 
0172 #define OP_LB       040
0173 #define OP_LH       041
0174 #define OP_LWL      042
0175 #define OP_LW       043
0176 #define OP_LBU      044
0177 #define OP_LHU      045
0178 #define OP_LWR      046
0179 #define OP_LWU      047
0180 
0181 #define OP_SB       050
0182 #define OP_SH       051
0183 #define OP_SWL      052
0184 #define OP_SW       053
0185 #define OP_SDL      054
0186 #define OP_SDR      055
0187 #define OP_SWR      056
0188 #define OP_CACHE    057
0189 
0190 #define OP_LL       060
0191 #define OP_LWC1     061
0192 #define OP_LWC2     062
0193 #define OP_LLD      064
0194 #define OP_LDC1     065
0195 #define OP_LDC2     066
0196 #define OP_LD       067
0197 
0198 #define OP_SC       070
0199 #define OP_SWC1     071
0200 #define OP_SWC2     072
0201 #define OP_SCD      074
0202 #define OP_SDC1     075
0203 #define OP_SDC2     076
0204 #define OP_SD       077
0205 
0206 /**
0207  * @name 'func' field values when 'op' == OP_SPECIAL.
0208  * @{
0209  */
0210 
0211 #define OP_SLL      000
0212 #define OP_SRL      002
0213 #define OP_SRA      003
0214 #define OP_SLLV     004
0215 #define OP_SRLV     006
0216 #define OP_SRAV     007
0217 
0218 #define OP_JR       010
0219 #define OP_JALR     011
0220 #define OP_SYSCALL  014
0221 #define OP_BREAK    015
0222 #define OP_SYNC     017
0223 
0224 #define OP_MFHI     020
0225 #define OP_MTHI     021
0226 #define OP_MFLO     022
0227 #define OP_MTLO     023
0228 #define OP_DSLLV    024
0229 #define OP_DSRLV    026
0230 #define OP_DSRAV    027
0231 
0232 #define OP_MULT     030
0233 #define OP_MULTU    031
0234 #define OP_DIV      032
0235 #define OP_DIVU     033
0236 #define OP_DMULT    034
0237 #define OP_DMULTU   035
0238 #define OP_DDIV     036
0239 #define OP_DDIVU    037
0240 
0241 #define OP_ADD      040
0242 #define OP_ADDU     041
0243 #define OP_SUB      042
0244 #define OP_SUBU     043
0245 #define OP_AND      044
0246 #define OP_OR       045
0247 #define OP_XOR      046
0248 #define OP_NOR      047
0249 
0250 #define OP_SLT      052
0251 #define OP_SLTU     053
0252 #define OP_DADD     054
0253 #define OP_DADDU    055
0254 #define OP_DSUB     056
0255 #define OP_DSUBU    057
0256 
0257 #define OP_TGE      060
0258 #define OP_TGEU     061
0259 #define OP_TLT      062
0260 #define OP_TLTU     063
0261 #define OP_TEQ      064
0262 #define OP_TNE      066
0263 
0264 #define OP_DSLL     070
0265 #define OP_DSRL     072
0266 #define OP_DSRA     073
0267 #define OP_DSLL32   074
0268 #define OP_DSRL32   076
0269 #define OP_DSRA32   077
0270 
0271 /** @} */
0272 
0273 /**
0274  * 'func' field values when 'op' == OP_REGIMM.
0275  * @{
0276  */
0277 
0278 #define OP_BLTZ     000
0279 #define OP_BGEZ     001
0280 #define OP_BLTZL    002
0281 #define OP_BGEZL    003
0282 
0283 #define OP_TGEI     010
0284 #define OP_TGEIU    011
0285 #define OP_TLTI     012
0286 #define OP_TLTIU    013
0287 #define OP_TEQI     014
0288 #define OP_TNEI     016
0289 
0290 #define OP_BLTZAL   020
0291 #define OP_BGEZAL   021
0292 #define OP_BLTZALL  022
0293 #define OP_BGEZALL  023
0294 
0295 /** @} */
0296 
0297 /**
0298  * @name 'rs' field values when 'op' == OP_COPz.
0299  * @{
0300  */
0301 
0302 #define OP_MF       000
0303 #define OP_DMF      001
0304 #define OP_CF       002
0305 #define OP_MT       004
0306 #define OP_DMT      005
0307 #define OP_CT       006
0308 #define OP_BC       010
0309 
0310 /** @} */
0311 
0312 /**
0313  * @name 'rt' field values when 'op' == OP_COPz and 'rt' == OP_BC.
0314  * @{
0315  */
0316 
0317 #define COPz_BCF    0x00
0318 #define COPz_BCT    0x01
0319 #define COPz_BCFL   0x02
0320 #define COPz_BCTL   0x03
0321 
0322 /** @} */
0323 
0324 /**
0325  * @name Instructions with specal significance to debuggers.
0326  * @{
0327  */
0328 
0329 #define BREAK_INSTR 0x0000000d  ///< @brief instruction code for break
0330 #define NOP_INSTR   0x00000000  ///< @brief instruction code for no-op
0331 
0332 /** @} */
0333 
0334 /** @} */
0335 
0336 #endif  /* _MIPS_OPCODE_H */