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