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/10/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 } InstFmt; 57 58 /* 59 * Values for the 'op' field. 60 */ 61 #define OP_SPECIAL 000 62 #define OP_BCOND 001 63 #define OP_J 002 64 #define OP_JAL 003 65 #define OP_BEQ 004 66 #define OP_BNE 005 67 #define OP_BLEZ 006 68 #define OP_BGTZ 007 69 70 #define OP_ADDI 010 71 #define OP_ADDIU 011 72 #define OP_SLTI 012 73 #define OP_SLTIU 013 74 #define OP_ANDI 014 75 #define OP_ORI 015 76 #define OP_XORI 016 77 #define OP_LUI 017 78 79 #define OP_COP0 020 80 #define OP_COP1 021 81 #define OP_COP2 022 82 #define OP_COP3 023 83 84 #define OP_LB 040 85 #define OP_LH 041 86 #define OP_LWL 042 87 #define OP_LW 043 88 #define OP_LBU 044 89 #define OP_LHU 045 90 #define OP_LWR 046 91 92 #define OP_SB 050 93 #define OP_SH 051 94 #define OP_SWL 052 95 #define OP_SW 053 96 #define OP_SWR 056 97 98 #define OP_LWC0 060 99 #define OP_LWC1 061 100 #define OP_LWC2 062 101 #define OP_LWC3 063 102 103 #define OP_SWC0 070 104 #define OP_SWC1 071 105 #define OP_SWC2 072 106 #define OP_SWC3 073 107 108 /* 109 * Values for the 'func' field when 'op' == OP_SPECIAL. 110 */ 111 #define OP_SLL 000 112 #define OP_SRL 002 113 #define OP_SRA 003 114 #define OP_SLLV 004 115 #define OP_SRLV 006 116 #define OP_SRAV 007 117 118 #define OP_JR 010 119 #define OP_JALR 011 120 #define OP_SYSCALL 014 121 #define OP_BREAK 015 122 123 #define OP_MFHI 020 124 #define OP_MTHI 021 125 #define OP_MFLO 022 126 #define OP_MTLO 023 127 128 #define OP_MULT 030 129 #define OP_MULTU 031 130 #define OP_DIV 032 131 #define OP_DIVU 033 132 133 #define OP_ADD 040 134 #define OP_ADDU 041 135 #define OP_SUB 042 136 #define OP_SUBU 043 137 #define OP_AND 044 138 #define OP_OR 045 139 #define OP_XOR 046 140 #define OP_NOR 047 141 142 #define OP_SLT 052 143 #define OP_SLTU 053 144 145 /* 146 * Values for the 'func' field when 'op' == OP_BCOND. 147 */ 148 #define OP_BLTZ 000 149 #define OP_BGEZ 001 150 #define OP_BLTZAL 020 151 #define OP_BGEZAL 021 152 153 /* 154 * Values for the 'rs' field when 'op' == OP_COPz. 155 */ 156 #define OP_MF 000 157 #define OP_MT 004 158 #define OP_BCx 010 159 #define OP_BCy 014 160 #define OP_CF 002 161 #define OP_CT 006 162 163 /* 164 * Values for the 'rt' field when 'op' == OP_COPz. 165 */ 166 #define COPz_BC_TF_MASK 0x01 167 #define COPz_BC_TRUE 0x01 168 #define COPz_BC_FALSE 0x00 169