1 /*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Ralph Campbell. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)mips_opcode.h 8.1 (Berkeley) 06/11/93 11 */ 12 13 /* 14 * Define the instruction formats and opcode values for the 15 * MIPS instruction set. 16 */ 17 18 /* 19 * Define the instruction formats. 20 */ 21 typedef union { 22 unsigned word; 23 24 #if BYTE_ORDER == LITTLE_ENDIAN 25 struct { 26 unsigned imm: 16; 27 unsigned rt: 5; 28 unsigned rs: 5; 29 unsigned op: 6; 30 } IType; 31 32 struct { 33 unsigned target: 26; 34 unsigned op: 6; 35 } JType; 36 37 struct { 38 unsigned func: 6; 39 unsigned shamt: 5; 40 unsigned rd: 5; 41 unsigned rt: 5; 42 unsigned rs: 5; 43 unsigned op: 6; 44 } RType; 45 46 struct { 47 unsigned func: 6; 48 unsigned fd: 5; 49 unsigned fs: 5; 50 unsigned ft: 5; 51 unsigned fmt: 4; 52 unsigned : 1; /* always '1' */ 53 unsigned op: 6; /* always '0x11' */ 54 } FRType; 55 #endif 56 #if BYTE_ORDER == BIG_ENDIAN 57 struct { 58 unsigned op: 6; 59 unsigned rs: 5; 60 unsigned rt: 5; 61 unsigned imm: 16; 62 } IType; 63 64 struct { 65 unsigned op: 6; 66 unsigned target: 26; 67 } JType; 68 69 struct { 70 unsigned op: 6; 71 unsigned rs: 5; 72 unsigned rt: 5; 73 unsigned rd: 5; 74 unsigned shamt: 5; 75 unsigned func: 6; 76 } RType; 77 78 struct { 79 unsigned op: 6; /* always '0x11' */ 80 unsigned : 1; /* always '1' */ 81 unsigned fmt: 4; 82 unsigned ft: 5; 83 unsigned fs: 5; 84 unsigned fd: 5; 85 unsigned func: 6; 86 } FRType; 87 #endif 88 } InstFmt; 89 90 /* 91 * Values for the 'op' field. 92 */ 93 #define OP_SPECIAL 000 94 #define OP_BCOND 001 95 #define OP_J 002 96 #define OP_JAL 003 97 #define OP_BEQ 004 98 #define OP_BNE 005 99 #define OP_BLEZ 006 100 #define OP_BGTZ 007 101 102 #define OP_ADDI 010 103 #define OP_ADDIU 011 104 #define OP_SLTI 012 105 #define OP_SLTIU 013 106 #define OP_ANDI 014 107 #define OP_ORI 015 108 #define OP_XORI 016 109 #define OP_LUI 017 110 111 #define OP_COP0 020 112 #define OP_COP1 021 113 #define OP_COP2 022 114 #define OP_COP3 023 115 116 #define OP_LB 040 117 #define OP_LH 041 118 #define OP_LWL 042 119 #define OP_LW 043 120 #define OP_LBU 044 121 #define OP_LHU 045 122 #define OP_LWR 046 123 124 #define OP_SB 050 125 #define OP_SH 051 126 #define OP_SWL 052 127 #define OP_SW 053 128 #define OP_SWR 056 129 130 #define OP_LWC0 060 131 #define OP_LWC1 061 132 #define OP_LWC2 062 133 #define OP_LWC3 063 134 135 #define OP_SWC0 070 136 #define OP_SWC1 071 137 #define OP_SWC2 072 138 #define OP_SWC3 073 139 140 /* 141 * Values for the 'func' field when 'op' == OP_SPECIAL. 142 */ 143 #define OP_SLL 000 144 #define OP_SRL 002 145 #define OP_SRA 003 146 #define OP_SLLV 004 147 #define OP_SRLV 006 148 #define OP_SRAV 007 149 150 #define OP_JR 010 151 #define OP_JALR 011 152 #define OP_SYSCALL 014 153 #define OP_BREAK 015 154 155 #define OP_MFHI 020 156 #define OP_MTHI 021 157 #define OP_MFLO 022 158 #define OP_MTLO 023 159 160 #define OP_MULT 030 161 #define OP_MULTU 031 162 #define OP_DIV 032 163 #define OP_DIVU 033 164 165 #define OP_ADD 040 166 #define OP_ADDU 041 167 #define OP_SUB 042 168 #define OP_SUBU 043 169 #define OP_AND 044 170 #define OP_OR 045 171 #define OP_XOR 046 172 #define OP_NOR 047 173 174 #define OP_SLT 052 175 #define OP_SLTU 053 176 177 /* 178 * Values for the 'func' field when 'op' == OP_BCOND. 179 */ 180 #define OP_BLTZ 000 181 #define OP_BGEZ 001 182 #define OP_BLTZAL 020 183 #define OP_BGEZAL 021 184 185 /* 186 * Values for the 'rs' field when 'op' == OP_COPz. 187 */ 188 #define OP_MF 000 189 #define OP_MT 004 190 #define OP_BCx 010 191 #define OP_BCy 014 192 #define OP_CF 002 193 #define OP_CT 006 194 195 /* 196 * Values for the 'rt' field when 'op' == OP_COPz. 197 */ 198 #define COPz_BC_TF_MASK 0x01 199 #define COPz_BC_TRUE 0x01 200 #define COPz_BC_FALSE 0x00 201