1*0472e113SJosef 'Jeff' Sipek /*
2*0472e113SJosef 'Jeff' Sipek  * This file and its contents are supplied under the terms of the
3*0472e113SJosef 'Jeff' Sipek  * Common Development and Distribution License ("CDDL"), version 1.0.
4*0472e113SJosef 'Jeff' Sipek  * You may only use this file in accordance with the terms of version
5*0472e113SJosef 'Jeff' Sipek  * 1.0 of the CDDL.
6*0472e113SJosef 'Jeff' Sipek  *
7*0472e113SJosef 'Jeff' Sipek  * A full copy of the text of the CDDL should have accompanied this
8*0472e113SJosef 'Jeff' Sipek  * source.  A copy of the CDDL is also available via the Internet at
9*0472e113SJosef 'Jeff' Sipek  * http://www.illumos.org/license/CDDL.
10*0472e113SJosef 'Jeff' Sipek  */
11*0472e113SJosef 'Jeff' Sipek 
12*0472e113SJosef 'Jeff' Sipek /*
13*0472e113SJosef 'Jeff' Sipek  * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
14*0472e113SJosef 'Jeff' Sipek  */
15*0472e113SJosef 'Jeff' Sipek 
16*0472e113SJosef 'Jeff' Sipek #include <stdio.h>
17*0472e113SJosef 'Jeff' Sipek #include <libdisasm.h>
18*0472e113SJosef 'Jeff' Sipek #include <sys/sysmacros.h>
19*0472e113SJosef 'Jeff' Sipek #include <sys/debug.h>
20*0472e113SJosef 'Jeff' Sipek #include <sys/byteorder.h>
21*0472e113SJosef 'Jeff' Sipek 
22*0472e113SJosef 'Jeff' Sipek #include "libdisasm_impl.h"
23*0472e113SJosef 'Jeff' Sipek 
24*0472e113SJosef 'Jeff' Sipek #define	ILC2LEN(ilc)	(2 * ((ilc) >= 2 ? (ilc) : (ilc) + 1))
25*0472e113SJosef 'Jeff' Sipek 
26*0472e113SJosef 'Jeff' Sipek /*
27*0472e113SJosef 'Jeff' Sipek  * Throughout this file, the instruction format names based on:
28*0472e113SJosef 'Jeff' Sipek  *   SA22-7832-09  z/Architecture Principles of Operation
29*0472e113SJosef 'Jeff' Sipek  *
30*0472e113SJosef 'Jeff' Sipek  * System/370, ESA/390, and earlier z/Architecture POP use slightly
31*0472e113SJosef 'Jeff' Sipek  * different names for the formats (the variant names are numeric).  For the
32*0472e113SJosef 'Jeff' Sipek  * sake of simplicity, we use the most detailed definitions - z/Architecture.
33*0472e113SJosef 'Jeff' Sipek  *
34*0472e113SJosef 'Jeff' Sipek  * For ESA/390 we map the formats:
35*0472e113SJosef 'Jeff' Sipek  *   E   -> E
36*0472e113SJosef 'Jeff' Sipek  *   I   -> I
37*0472e113SJosef 'Jeff' Sipek  *   RR  -> RR
38*0472e113SJosef 'Jeff' Sipek  *   RRE -> RRE
39*0472e113SJosef 'Jeff' Sipek  *   RRF -> RRD & RRFa-e
40*0472e113SJosef 'Jeff' Sipek  *   RX  -> RXa-b
41*0472e113SJosef 'Jeff' Sipek  *   RXE -> RXE
42*0472e113SJosef 'Jeff' Sipek  *   RXF -> RXF
43*0472e113SJosef 'Jeff' Sipek  *   RS  -> RSa-b
44*0472e113SJosef 'Jeff' Sipek  *   RSE -> RSYa-b
45*0472e113SJosef 'Jeff' Sipek  *   RSL -> RSLa
46*0472e113SJosef 'Jeff' Sipek  *   RSI -> RSI
47*0472e113SJosef 'Jeff' Sipek  *   RI  -> RIa-c
48*0472e113SJosef 'Jeff' Sipek  *   RIL -> RILa-c
49*0472e113SJosef 'Jeff' Sipek  *   SI  -> SI
50*0472e113SJosef 'Jeff' Sipek  *   S   -> S
51*0472e113SJosef 'Jeff' Sipek  *   SS  -> SSa-b & SSd-e
52*0472e113SJosef 'Jeff' Sipek  *   SSE -> SSE
53*0472e113SJosef 'Jeff' Sipek  *
54*0472e113SJosef 'Jeff' Sipek  * For System/370 we map the formats:
55*0472e113SJosef 'Jeff' Sipek  *   RR -> RR
56*0472e113SJosef 'Jeff' Sipek  *   RX -> RXa-b
57*0472e113SJosef 'Jeff' Sipek  *   RS -> RSa-b
58*0472e113SJosef 'Jeff' Sipek  *   SI -> SI
59*0472e113SJosef 'Jeff' Sipek  *   S  -> S
60*0472e113SJosef 'Jeff' Sipek  *   SS -> SSa-c
61*0472e113SJosef 'Jeff' Sipek  *
62*0472e113SJosef 'Jeff' Sipek  * Disassembly begins in tbl_xx.  The first byte of the instruction is used
63*0472e113SJosef 'Jeff' Sipek  * as the index.  This yields either an instruction or a sub-table.
64*0472e113SJosef 'Jeff' Sipek  *
65*0472e113SJosef 'Jeff' Sipek  * If an instruction is encountered, its format field is used to format the
66*0472e113SJosef 'Jeff' Sipek  * instruction.
67*0472e113SJosef 'Jeff' Sipek  *
68*0472e113SJosef 'Jeff' Sipek  * There are two types of sub-tables: extended opcode tables (indicated with
69*0472e113SJosef 'Jeff' Sipek  * IF_TBL) or a multiple mnemonics tables (indicated with IF_MULTI).
70*0472e113SJosef 'Jeff' Sipek  *
71*0472e113SJosef 'Jeff' Sipek  * Extended opcode tables indicade which additional bits of the instruction
72*0472e113SJosef 'Jeff' Sipek  * should be inspected.  These bits are used as an index into the sub table.
73*0472e113SJosef 'Jeff' Sipek  *
74*0472e113SJosef 'Jeff' Sipek  * Multiple mnemonic tables are used to print different mnemonics depending
75*0472e113SJosef 'Jeff' Sipek  * on the architecture.  Over the years, certain instructions got a new
76*0472e113SJosef 'Jeff' Sipek  * preferred mnemonic.  For example, 0xa70 is test-under-mask-high (tmh) on
77*0472e113SJosef 'Jeff' Sipek  * System/390.  On z/Architecture systems, the instruction behaves
78*0472e113SJosef 'Jeff' Sipek  * identically (and the assembler hapilly accepts tmh), but the preferred
79*0472e113SJosef 'Jeff' Sipek  * mnemonic is tmlh (test-under-mask-low-high) because z/Architecture
80*0472e113SJosef 'Jeff' Sipek  * extended the general purpose registers from 32 bits to 64 bits.  The
81*0472e113SJosef 'Jeff' Sipek  * current architecture flag (e.g., F_390) is used to index into the
82*0472e113SJosef 'Jeff' Sipek  * sub-table.
83*0472e113SJosef 'Jeff' Sipek  *
84*0472e113SJosef 'Jeff' Sipek  * Regardless of which sub-table is encountered, the selected entry in the
85*0472e113SJosef 'Jeff' Sipek  * sub-table is interpreted using the same rules as the contents of tbl_xx.
86*0472e113SJosef 'Jeff' Sipek  *
87*0472e113SJosef 'Jeff' Sipek  * Finally, we use the extended opcode sub-table mechanism to pretty print
88*0472e113SJosef 'Jeff' Sipek  * the branching instructions.  All branches are conditional based on a
89*0472e113SJosef 'Jeff' Sipek  * 4-bit mask indicating which value of the condition code will result in a
90*0472e113SJosef 'Jeff' Sipek  * taken branch.  In order to produce a more human friendly output, we use
91*0472e113SJosef 'Jeff' Sipek  * the 4-bit mask as an extended opcode to break up the branching
92*0472e113SJosef 'Jeff' Sipek  * instruction into 16 different ones.  For example, instead of printing:
93*0472e113SJosef 'Jeff' Sipek  *
94*0472e113SJosef 'Jeff' Sipek  *    bc   7,0x123(%r1,%r2)
95*0472e113SJosef 'Jeff' Sipek  *
96*0472e113SJosef 'Jeff' Sipek  * we print:
97*0472e113SJosef 'Jeff' Sipek  *
98*0472e113SJosef 'Jeff' Sipek  *    bne  0x123(%r1,%r2)
99*0472e113SJosef 'Jeff' Sipek  *
100*0472e113SJosef 'Jeff' Sipek  * Note that we are using designated initializers via the INSTR/TABLE/MULTI
101*0472e113SJosef 'Jeff' Sipek  * macros and therefore the below tables can be sparse.  We rely on unset
102*0472e113SJosef 'Jeff' Sipek  * entries having zero format fields (aka. IF_INVAL) per C99.
103*0472e113SJosef 'Jeff' Sipek  */
104*0472e113SJosef 'Jeff' Sipek 
105*0472e113SJosef 'Jeff' Sipek /* BEGIN CSTYLED */
106*0472e113SJosef 'Jeff' Sipek enum ifmt {
107*0472e113SJosef 'Jeff' Sipek 	/* invalid */
108*0472e113SJosef 'Jeff' Sipek 	IF_INVAL = 0,
109*0472e113SJosef 'Jeff' Sipek 
110*0472e113SJosef 'Jeff' Sipek 	/* indirection */
111*0472e113SJosef 'Jeff' Sipek 	IF_TBL,
112*0472e113SJosef 'Jeff' Sipek 	IF_MULTI,
113*0472e113SJosef 'Jeff' Sipek 
114*0472e113SJosef 'Jeff' Sipek 	/* 2-byte */
115*0472e113SJosef 'Jeff' Sipek 	IF_ZERO,		/* 370, 390, z */
116*0472e113SJosef 'Jeff' Sipek 	IF_E,			/*      390, z */
117*0472e113SJosef 'Jeff' Sipek 	IF_I,			/*      390, z */
118*0472e113SJosef 'Jeff' Sipek 	IF_RR,			/* 370, 390, z */
119*0472e113SJosef 'Jeff' Sipek 
120*0472e113SJosef 'Jeff' Sipek 	/* 4-byte */
121*0472e113SJosef 'Jeff' Sipek 	IF_DIAG,		/* 370, 390, z */
122*0472e113SJosef 'Jeff' Sipek 	IF_IE,			/*           z */
123*0472e113SJosef 'Jeff' Sipek 	IF_RIa,			/*      390, z */
124*0472e113SJosef 'Jeff' Sipek 	IF_RIb,			/*      390, z */
125*0472e113SJosef 'Jeff' Sipek 	IF_RIc,			/*      390, z */
126*0472e113SJosef 'Jeff' Sipek 	IF_RRD,			/*      390, z */ /* on 390 these are RRF */
127*0472e113SJosef 'Jeff' Sipek 	IF_RRE,			/*      390, z */
128*0472e113SJosef 'Jeff' Sipek 	IF_RRFa,		/*      390, z */
129*0472e113SJosef 'Jeff' Sipek 	IF_RRFb,		/*      390, z */
130*0472e113SJosef 'Jeff' Sipek 	IF_RRFc,		/*      390, z */
131*0472e113SJosef 'Jeff' Sipek 	IF_RRFd,		/*      390, z */
132*0472e113SJosef 'Jeff' Sipek 	IF_RRFe,		/*      390, z */
133*0472e113SJosef 'Jeff' Sipek 	IF_RSa,			/* 370, 390, z */
134*0472e113SJosef 'Jeff' Sipek 	IF_RSb,			/* 370, 390, z */
135*0472e113SJosef 'Jeff' Sipek 	IF_RSI,			/*      390, z */
136*0472e113SJosef 'Jeff' Sipek 	IF_RXa,			/* 370, 390, z */
137*0472e113SJosef 'Jeff' Sipek 	IF_RXb,			/* 370, 390, z */
138*0472e113SJosef 'Jeff' Sipek 	IF_S,			/* 370, 390, z */
139*0472e113SJosef 'Jeff' Sipek 	IF_SI,			/* 370, 390, z */
140*0472e113SJosef 'Jeff' Sipek 
141*0472e113SJosef 'Jeff' Sipek 	/* 6-byte */
142*0472e113SJosef 'Jeff' Sipek 	IF_MII,			/*           z */
143*0472e113SJosef 'Jeff' Sipek 	IF_RIEa,		/*           z */
144*0472e113SJosef 'Jeff' Sipek 	IF_RIEb,		/*           z */
145*0472e113SJosef 'Jeff' Sipek 	IF_RIEc,		/*           z */
146*0472e113SJosef 'Jeff' Sipek 	IF_RIEd,		/*           z */
147*0472e113SJosef 'Jeff' Sipek 	IF_RIEe,		/*           z */
148*0472e113SJosef 'Jeff' Sipek 	IF_RIEf,		/*           z */
149*0472e113SJosef 'Jeff' Sipek 	IF_RILa,		/*      390, z */
150*0472e113SJosef 'Jeff' Sipek 	IF_RILb,		/*      390, z */
151*0472e113SJosef 'Jeff' Sipek 	IF_RILc,		/*      390, z */
152*0472e113SJosef 'Jeff' Sipek 	IF_RIS,			/*           z */
153*0472e113SJosef 'Jeff' Sipek 	IF_RRS,			/*           z */
154*0472e113SJosef 'Jeff' Sipek 	IF_RSLa,		/*      390, z */
155*0472e113SJosef 'Jeff' Sipek 	IF_RSLb,		/*           z */
156*0472e113SJosef 'Jeff' Sipek 	IF_RSYa,		/*           z */
157*0472e113SJosef 'Jeff' Sipek 	IF_RSYb,		/*           z */
158*0472e113SJosef 'Jeff' Sipek 	IF_RXE,			/*      390, z */
159*0472e113SJosef 'Jeff' Sipek 	IF_RXF,			/*      390, z */
160*0472e113SJosef 'Jeff' Sipek 	IF_RXYa,		/*           z */
161*0472e113SJosef 'Jeff' Sipek 	IF_RXYb,		/*           z */
162*0472e113SJosef 'Jeff' Sipek 	IF_SIL,			/*           z */
163*0472e113SJosef 'Jeff' Sipek 	IF_SIY,			/*           z */
164*0472e113SJosef 'Jeff' Sipek 	IF_SMI,			/*           z */
165*0472e113SJosef 'Jeff' Sipek 	IF_SSa,			/* 370, 390, z */
166*0472e113SJosef 'Jeff' Sipek 	IF_SSb,			/* 370, 390, z */
167*0472e113SJosef 'Jeff' Sipek 	IF_SSc,			/* 370, 390, z */
168*0472e113SJosef 'Jeff' Sipek 	IF_SSd,			/*      390, z */
169*0472e113SJosef 'Jeff' Sipek 	IF_SSe,			/*      390, z */
170*0472e113SJosef 'Jeff' Sipek 	IF_SSf,			/*      390, z */
171*0472e113SJosef 'Jeff' Sipek 	IF_SSE,			/*      390, z */
172*0472e113SJosef 'Jeff' Sipek 	IF_SSF,			/*           z */
173*0472e113SJosef 'Jeff' Sipek };
174*0472e113SJosef 'Jeff' Sipek 
175*0472e113SJosef 'Jeff' Sipek #define	IF_NFMTS		(IF_SSF + 1)
176*0472e113SJosef 'Jeff' Sipek 
177*0472e113SJosef 'Jeff' Sipek #define	F_370			0x0001			/* 370         */
178*0472e113SJosef 'Jeff' Sipek #define	F_390			0x0002			/*      390    */
179*0472e113SJosef 'Jeff' Sipek #define	F_Z			0x0004			/*           z */
180*0472e113SJosef 'Jeff' Sipek #define	F_SIGNED_IMM		0x0010			/* 370, 390, z */
181*0472e113SJosef 'Jeff' Sipek #define	F_CTL_REG		0x0020			/* 370, 390, z */
182*0472e113SJosef 'Jeff' Sipek #define	F_HIDE_MASK		0x0040			/* 370, 390, z */
183*0472e113SJosef 'Jeff' Sipek #define	F_R1_IS_MASK		0x0080			/* 370, 390, z */
184*0472e113SJosef 'Jeff' Sipek /* END CSTYLED */
185*0472e113SJosef 'Jeff' Sipek 
186*0472e113SJosef 'Jeff' Sipek struct inst_table {
187*0472e113SJosef 'Jeff' Sipek 	union {
188*0472e113SJosef 'Jeff' Sipek 		struct {
189*0472e113SJosef 'Jeff' Sipek 			const char *it_name;
190*0472e113SJosef 'Jeff' Sipek 			unsigned it_flags;
191*0472e113SJosef 'Jeff' Sipek 		} it_inst;
192*0472e113SJosef 'Jeff' Sipek 		struct {
193*0472e113SJosef 'Jeff' Sipek 			const struct inst_table *it_ptr;
194*0472e113SJosef 'Jeff' Sipek 			uint8_t it_off:4;
195*0472e113SJosef 'Jeff' Sipek 			uint8_t it_shift:4;
196*0472e113SJosef 'Jeff' Sipek 			uint8_t it_mask;
197*0472e113SJosef 'Jeff' Sipek 		} it_table;
198*0472e113SJosef 'Jeff' Sipek 		struct {
199*0472e113SJosef 'Jeff' Sipek 			const struct inst_table *it_ptr;
200*0472e113SJosef 'Jeff' Sipek 		} it_multi;
201*0472e113SJosef 'Jeff' Sipek 	} it_u;
202*0472e113SJosef 'Jeff' Sipek 	enum ifmt it_fmt;
203*0472e113SJosef 'Jeff' Sipek };
204*0472e113SJosef 'Jeff' Sipek 
205*0472e113SJosef 'Jeff' Sipek #define	BITFLD(a, b)		DECL_BITFIELD2(b:4, a:4)
206*0472e113SJosef 'Jeff' Sipek 
207*0472e113SJosef 'Jeff' Sipek union inst {
208*0472e113SJosef 'Jeff' Sipek 	uint8_t raw[6];
209*0472e113SJosef 'Jeff' Sipek 	struct {
210*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
211*0472e113SJosef 'Jeff' Sipek 		uint8_t par1;
212*0472e113SJosef 'Jeff' Sipek 		uint16_t par2;
213*0472e113SJosef 'Jeff' Sipek 	} diag;
214*0472e113SJosef 'Jeff' Sipek 	struct {
215*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
216*0472e113SJosef 'Jeff' Sipek 		uint8_t i;
217*0472e113SJosef 'Jeff' Sipek 	} i;
218*0472e113SJosef 'Jeff' Sipek 	struct {
219*0472e113SJosef 'Jeff' Sipek 		uint16_t op;
220*0472e113SJosef 'Jeff' Sipek 		uint8_t pad;
221*0472e113SJosef 'Jeff' Sipek 		BITFLD(i1, i2);
222*0472e113SJosef 'Jeff' Sipek 	} ie;
223*0472e113SJosef 'Jeff' Sipek 	struct {
224*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
225*0472e113SJosef 'Jeff' Sipek 		BITFLD(m1, ri2h);
226*0472e113SJosef 'Jeff' Sipek 		uint8_t ri2l;
227*0472e113SJosef 'Jeff' Sipek 		uint8_t ri3h;
228*0472e113SJosef 'Jeff' Sipek 		uint16_t ri3l;
229*0472e113SJosef 'Jeff' Sipek 	} mii;
230*0472e113SJosef 'Jeff' Sipek 	struct {
231*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
232*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r2);
233*0472e113SJosef 'Jeff' Sipek 	} rr;
234*0472e113SJosef 'Jeff' Sipek 	struct {
235*0472e113SJosef 'Jeff' Sipek 		uint16_t op;
236*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, pad);
237*0472e113SJosef 'Jeff' Sipek 		BITFLD(r3, r2);
238*0472e113SJosef 'Jeff' Sipek 	} rrd;
239*0472e113SJosef 'Jeff' Sipek 	struct {
240*0472e113SJosef 'Jeff' Sipek 		uint16_t op;
241*0472e113SJosef 'Jeff' Sipek 		uint8_t pad;
242*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r2);
243*0472e113SJosef 'Jeff' Sipek 	} rre;
244*0472e113SJosef 'Jeff' Sipek 	struct {
245*0472e113SJosef 'Jeff' Sipek 		uint16_t op;
246*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, m4);
247*0472e113SJosef 'Jeff' Sipek 		BITFLD(r3, r2);
248*0472e113SJosef 'Jeff' Sipek 	} rrf_ab;
249*0472e113SJosef 'Jeff' Sipek 	struct {
250*0472e113SJosef 'Jeff' Sipek 		uint16_t op;
251*0472e113SJosef 'Jeff' Sipek 		BITFLD(m3, m4);
252*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r2);
253*0472e113SJosef 'Jeff' Sipek 	} rrf_cde;
254*0472e113SJosef 'Jeff' Sipek 	struct {
255*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
256*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r2);
257*0472e113SJosef 'Jeff' Sipek 		BITFLD(b4, d4h);
258*0472e113SJosef 'Jeff' Sipek 		uint8_t d4l;
259*0472e113SJosef 'Jeff' Sipek 		BITFLD(m3, pad);
260*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
261*0472e113SJosef 'Jeff' Sipek 	} rrs;
262*0472e113SJosef 'Jeff' Sipek 	struct {
263*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
264*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, x2);
265*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
266*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
267*0472e113SJosef 'Jeff' Sipek 	} rx_a;
268*0472e113SJosef 'Jeff' Sipek 	struct {
269*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
270*0472e113SJosef 'Jeff' Sipek 		BITFLD(m1, x2);
271*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
272*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
273*0472e113SJosef 'Jeff' Sipek 	} rx_b;
274*0472e113SJosef 'Jeff' Sipek 	struct {
275*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
276*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, x2);
277*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
278*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
279*0472e113SJosef 'Jeff' Sipek 		uint8_t pad;
280*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
281*0472e113SJosef 'Jeff' Sipek 	} rxe;
282*0472e113SJosef 'Jeff' Sipek 	struct {
283*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
284*0472e113SJosef 'Jeff' Sipek 		BITFLD(r3, x2);
285*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
286*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
287*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, pad);
288*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
289*0472e113SJosef 'Jeff' Sipek 	} rxf;
290*0472e113SJosef 'Jeff' Sipek 	struct {
291*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
292*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, x2);
293*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, dl2h);
294*0472e113SJosef 'Jeff' Sipek 		uint8_t dl2l;
295*0472e113SJosef 'Jeff' Sipek 		uint8_t dh2;
296*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
297*0472e113SJosef 'Jeff' Sipek 	} rxy_a;
298*0472e113SJosef 'Jeff' Sipek 	struct {
299*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
300*0472e113SJosef 'Jeff' Sipek 		BITFLD(m1, x2);
301*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, dl2h);
302*0472e113SJosef 'Jeff' Sipek 		uint8_t dl2l;
303*0472e113SJosef 'Jeff' Sipek 		uint8_t dh2;
304*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
305*0472e113SJosef 'Jeff' Sipek 	} rxy_b;
306*0472e113SJosef 'Jeff' Sipek 	struct {
307*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
308*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r3);
309*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
310*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
311*0472e113SJosef 'Jeff' Sipek 	} rs_a;
312*0472e113SJosef 'Jeff' Sipek 	struct {
313*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
314*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, m3);
315*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
316*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
317*0472e113SJosef 'Jeff' Sipek 	} rs_b;
318*0472e113SJosef 'Jeff' Sipek 	struct {
319*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
320*0472e113SJosef 'Jeff' Sipek 		BITFLD(l1, pad1);
321*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
322*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
323*0472e113SJosef 'Jeff' Sipek 		uint8_t pad2;
324*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
325*0472e113SJosef 'Jeff' Sipek 	} rsl_a;
326*0472e113SJosef 'Jeff' Sipek 	struct {
327*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
328*0472e113SJosef 'Jeff' Sipek 		uint8_t l2;
329*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
330*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
331*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, m3);
332*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
333*0472e113SJosef 'Jeff' Sipek 	} rsl_b;
334*0472e113SJosef 'Jeff' Sipek 	struct {
335*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
336*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r3);
337*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2;
338*0472e113SJosef 'Jeff' Sipek 	} rsi;
339*0472e113SJosef 'Jeff' Sipek 	struct {
340*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
341*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r3);
342*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, dl2h);
343*0472e113SJosef 'Jeff' Sipek 		uint8_t dl2l;
344*0472e113SJosef 'Jeff' Sipek 		uint8_t dh2;
345*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
346*0472e113SJosef 'Jeff' Sipek 	} rsy_a;
347*0472e113SJosef 'Jeff' Sipek 	struct {
348*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
349*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, m3);
350*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, dl2h);
351*0472e113SJosef 'Jeff' Sipek 		uint8_t dl2l;
352*0472e113SJosef 'Jeff' Sipek 		uint8_t dh2;
353*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
354*0472e113SJosef 'Jeff' Sipek 	} rsy_b;
355*0472e113SJosef 'Jeff' Sipek 	struct {
356*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
357*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, op2);
358*0472e113SJosef 'Jeff' Sipek 		uint16_t i2;
359*0472e113SJosef 'Jeff' Sipek 	} ri_a;
360*0472e113SJosef 'Jeff' Sipek 	struct {
361*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
362*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, op2);
363*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2;
364*0472e113SJosef 'Jeff' Sipek 	} ri_b;
365*0472e113SJosef 'Jeff' Sipek 	struct {
366*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
367*0472e113SJosef 'Jeff' Sipek 		BITFLD(m1, op2);
368*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2;
369*0472e113SJosef 'Jeff' Sipek 	} ri_c;
370*0472e113SJosef 'Jeff' Sipek 	struct {
371*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
372*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, _pad0);
373*0472e113SJosef 'Jeff' Sipek 		uint16_t i2;
374*0472e113SJosef 'Jeff' Sipek 		BITFLD(m3, _pad1);
375*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
376*0472e113SJosef 'Jeff' Sipek 	} rie_a;
377*0472e113SJosef 'Jeff' Sipek 	struct {
378*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
379*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r2);
380*0472e113SJosef 'Jeff' Sipek 		uint16_t ri4;
381*0472e113SJosef 'Jeff' Sipek 		BITFLD(m3, _pad);
382*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
383*0472e113SJosef 'Jeff' Sipek 	} rie_b;
384*0472e113SJosef 'Jeff' Sipek 	struct {
385*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
386*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, m3);
387*0472e113SJosef 'Jeff' Sipek 		uint16_t ri4;
388*0472e113SJosef 'Jeff' Sipek 		uint8_t i2;
389*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
390*0472e113SJosef 'Jeff' Sipek 	} rie_c;
391*0472e113SJosef 'Jeff' Sipek 	struct {
392*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
393*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r3);
394*0472e113SJosef 'Jeff' Sipek 		uint16_t i2;
395*0472e113SJosef 'Jeff' Sipek 		uint8_t _pad;
396*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
397*0472e113SJosef 'Jeff' Sipek 	} rie_d;
398*0472e113SJosef 'Jeff' Sipek 	struct {
399*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
400*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r3);
401*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2;
402*0472e113SJosef 'Jeff' Sipek 		uint8_t _pad;
403*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
404*0472e113SJosef 'Jeff' Sipek 	} rie_e;
405*0472e113SJosef 'Jeff' Sipek 	struct {
406*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
407*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r2);
408*0472e113SJosef 'Jeff' Sipek 		uint8_t i3;
409*0472e113SJosef 'Jeff' Sipek 		uint8_t i4;
410*0472e113SJosef 'Jeff' Sipek 		uint8_t i5;
411*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
412*0472e113SJosef 'Jeff' Sipek 	} rie_f;
413*0472e113SJosef 'Jeff' Sipek 	struct {
414*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
415*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, op2);
416*0472e113SJosef 'Jeff' Sipek 		uint16_t i2h;
417*0472e113SJosef 'Jeff' Sipek 		uint16_t i2l;
418*0472e113SJosef 'Jeff' Sipek 	} ril_a;
419*0472e113SJosef 'Jeff' Sipek 	struct {
420*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
421*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, op2);
422*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2h;
423*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2l;
424*0472e113SJosef 'Jeff' Sipek 	} ril_b;
425*0472e113SJosef 'Jeff' Sipek 	struct {
426*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
427*0472e113SJosef 'Jeff' Sipek 		BITFLD(m1, op2);
428*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2h;
429*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2l;
430*0472e113SJosef 'Jeff' Sipek 	} ril_c;
431*0472e113SJosef 'Jeff' Sipek 	struct {
432*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
433*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, m3);
434*0472e113SJosef 'Jeff' Sipek 		BITFLD(b4, d4h);
435*0472e113SJosef 'Jeff' Sipek 		uint8_t d4l;
436*0472e113SJosef 'Jeff' Sipek 		uint8_t i2;
437*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
438*0472e113SJosef 'Jeff' Sipek 	} ris;
439*0472e113SJosef 'Jeff' Sipek 	struct {
440*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
441*0472e113SJosef 'Jeff' Sipek 		uint8_t i2;
442*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
443*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
444*0472e113SJosef 'Jeff' Sipek 	} si;
445*0472e113SJosef 'Jeff' Sipek 	struct {
446*0472e113SJosef 'Jeff' Sipek 		uint16_t op;
447*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
448*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
449*0472e113SJosef 'Jeff' Sipek 		uint16_t i2;
450*0472e113SJosef 'Jeff' Sipek 	} sil;
451*0472e113SJosef 'Jeff' Sipek 	struct {
452*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
453*0472e113SJosef 'Jeff' Sipek 		uint8_t i2;
454*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, dl1h);
455*0472e113SJosef 'Jeff' Sipek 		uint8_t dl1l;
456*0472e113SJosef 'Jeff' Sipek 		uint8_t dh1;
457*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
458*0472e113SJosef 'Jeff' Sipek 	} siy;
459*0472e113SJosef 'Jeff' Sipek 	struct {
460*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
461*0472e113SJosef 'Jeff' Sipek 		BITFLD(m1, pad);
462*0472e113SJosef 'Jeff' Sipek 		BITFLD(b3, d3h);
463*0472e113SJosef 'Jeff' Sipek 		uint8_t d3l;
464*0472e113SJosef 'Jeff' Sipek 		uint16_t ri2;
465*0472e113SJosef 'Jeff' Sipek 	} smi;
466*0472e113SJosef 'Jeff' Sipek 	struct {
467*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
468*0472e113SJosef 'Jeff' Sipek 		uint8_t op2;
469*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
470*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
471*0472e113SJosef 'Jeff' Sipek 	} s;
472*0472e113SJosef 'Jeff' Sipek 	struct {
473*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
474*0472e113SJosef 'Jeff' Sipek 		uint8_t l;
475*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
476*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
477*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
478*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
479*0472e113SJosef 'Jeff' Sipek 	} ss_a;
480*0472e113SJosef 'Jeff' Sipek 	struct {
481*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
482*0472e113SJosef 'Jeff' Sipek 		BITFLD(l1, l2);
483*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
484*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
485*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
486*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
487*0472e113SJosef 'Jeff' Sipek 	} ss_b;
488*0472e113SJosef 'Jeff' Sipek 	struct {
489*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
490*0472e113SJosef 'Jeff' Sipek 		BITFLD(l1, i3);
491*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
492*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
493*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
494*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
495*0472e113SJosef 'Jeff' Sipek 	} ss_c;
496*0472e113SJosef 'Jeff' Sipek 	struct {
497*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
498*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r3);
499*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
500*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
501*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
502*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
503*0472e113SJosef 'Jeff' Sipek 	} ss_d;
504*0472e113SJosef 'Jeff' Sipek 	struct {
505*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
506*0472e113SJosef 'Jeff' Sipek 		BITFLD(r1, r3);
507*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
508*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
509*0472e113SJosef 'Jeff' Sipek 		BITFLD(b4, d4h);
510*0472e113SJosef 'Jeff' Sipek 		uint8_t d4l;
511*0472e113SJosef 'Jeff' Sipek 	} ss_e;
512*0472e113SJosef 'Jeff' Sipek 	struct {
513*0472e113SJosef 'Jeff' Sipek 		uint8_t op;
514*0472e113SJosef 'Jeff' Sipek 		uint8_t l2;
515*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
516*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
517*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
518*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
519*0472e113SJosef 'Jeff' Sipek 	} ss_f;
520*0472e113SJosef 'Jeff' Sipek 	struct {
521*0472e113SJosef 'Jeff' Sipek 		uint16_t op;
522*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
523*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
524*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
525*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
526*0472e113SJosef 'Jeff' Sipek 	} sse;
527*0472e113SJosef 'Jeff' Sipek 	struct {
528*0472e113SJosef 'Jeff' Sipek 		uint8_t op1;
529*0472e113SJosef 'Jeff' Sipek 		BITFLD(r3, op2);
530*0472e113SJosef 'Jeff' Sipek 		BITFLD(b1, d1h);
531*0472e113SJosef 'Jeff' Sipek 		uint8_t d1l;
532*0472e113SJosef 'Jeff' Sipek 		BITFLD(b2, d2h);
533*0472e113SJosef 'Jeff' Sipek 		uint8_t d2l;
534*0472e113SJosef 'Jeff' Sipek 	} ssf;
535*0472e113SJosef 'Jeff' Sipek };
536*0472e113SJosef 'Jeff' Sipek 
537*0472e113SJosef 'Jeff' Sipek #define	INSTR(op, m, fm, fl)	[op] = { \
538*0472e113SJosef 'Jeff' Sipek 					.it_u.it_inst = { \
539*0472e113SJosef 'Jeff' Sipek 						.it_name = (m), \
540*0472e113SJosef 'Jeff' Sipek 						.it_flags = (fl), \
541*0472e113SJosef 'Jeff' Sipek 					}, \
542*0472e113SJosef 'Jeff' Sipek 					.it_fmt = (fm), \
543*0472e113SJosef 'Jeff' Sipek 				}
544*0472e113SJosef 'Jeff' Sipek #define	TABLE(op, tbl, o, s, m)	[op] = { \
545*0472e113SJosef 'Jeff' Sipek 					.it_u.it_table = { \
546*0472e113SJosef 'Jeff' Sipek 						.it_ptr = (tbl), \
547*0472e113SJosef 'Jeff' Sipek 						.it_off = (o), \
548*0472e113SJosef 'Jeff' Sipek 						.it_shift = (s), \
549*0472e113SJosef 'Jeff' Sipek 						.it_mask = (m), \
550*0472e113SJosef 'Jeff' Sipek 					}, \
551*0472e113SJosef 'Jeff' Sipek 					.it_fmt = IF_TBL, \
552*0472e113SJosef 'Jeff' Sipek 				}
553*0472e113SJosef 'Jeff' Sipek #define	MULTI(op, tbl)		[op] = { \
554*0472e113SJosef 'Jeff' Sipek 					.it_u.it_multi.it_ptr = (tbl), \
555*0472e113SJosef 'Jeff' Sipek 					.it_fmt = IF_MULTI, \
556*0472e113SJosef 'Jeff' Sipek 				}
557*0472e113SJosef 'Jeff' Sipek 
558*0472e113SJosef 'Jeff' Sipek /*
559*0472e113SJosef 'Jeff' Sipek  * Instruction tables based on:
560*0472e113SJosef 'Jeff' Sipek  *   GA22-7000-4   System/370 Principles of Operation
561*0472e113SJosef 'Jeff' Sipek  *   SA22-7201-08  ESA/390 Principles of Operation
562*0472e113SJosef 'Jeff' Sipek  *   SA22-7832-09  z/Architecture Principles of Operation
563*0472e113SJosef 'Jeff' Sipek  */
564*0472e113SJosef 'Jeff' Sipek 
565*0472e113SJosef 'Jeff' Sipek /* BEGIN CSTYLED */
566*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_01xx[256] = {
567*0472e113SJosef 'Jeff' Sipek 	INSTR(0x01, "pr",    IF_E, F_390 | F_Z),
568*0472e113SJosef 'Jeff' Sipek 	INSTR(0x02, "upt",   IF_E, F_390 | F_Z),
569*0472e113SJosef 'Jeff' Sipek 	INSTR(0x04, "ptff",  IF_E, F_Z),
570*0472e113SJosef 'Jeff' Sipek 	INSTR(0x07, "sckpf", IF_E, F_390 | F_Z),
571*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0a, "pfpo",  IF_E, F_Z),
572*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0b, "tam",   IF_E, F_390 | F_Z),
573*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0c, "sam24", IF_E, F_390 | F_Z),
574*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0d, "sam31", IF_E, F_390 | F_Z),
575*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0e, "sam64", IF_E, F_Z),
576*0472e113SJosef 'Jeff' Sipek 	INSTR(0xff, "trap2", IF_E, F_390 | F_Z),
577*0472e113SJosef 'Jeff' Sipek };
578*0472e113SJosef 'Jeff' Sipek 
579*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_07[] = {
580*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0, "nopr",  IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
581*0472e113SJosef 'Jeff' Sipek 	INSTR(0x1, "bor",   IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
582*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2, "bhr",   IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
583*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3, "bcr",   IF_RR, F_370 | F_390 | F_Z | F_R1_IS_MASK),
584*0472e113SJosef 'Jeff' Sipek 	INSTR(0x4, "blr",   IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
585*0472e113SJosef 'Jeff' Sipek 	INSTR(0x5, "bcr",   IF_RR, F_370 | F_390 | F_Z | F_R1_IS_MASK),
586*0472e113SJosef 'Jeff' Sipek 	INSTR(0x6, "bcr",   IF_RR, F_370 | F_390 | F_Z | F_R1_IS_MASK),
587*0472e113SJosef 'Jeff' Sipek 	INSTR(0x7, "bnzr",  IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
588*0472e113SJosef 'Jeff' Sipek 	INSTR(0x8, "ber",   IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
589*0472e113SJosef 'Jeff' Sipek 	INSTR(0x9, "bcr",   IF_RR, F_370 | F_390 | F_Z | F_R1_IS_MASK),
590*0472e113SJosef 'Jeff' Sipek 	INSTR(0xa, "bcr",   IF_RR, F_370 | F_390 | F_Z | F_R1_IS_MASK),
591*0472e113SJosef 'Jeff' Sipek 	INSTR(0xb, "bner",  IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
592*0472e113SJosef 'Jeff' Sipek 	INSTR(0xc, "bcr",   IF_RR, F_370 | F_390 | F_Z | F_R1_IS_MASK),
593*0472e113SJosef 'Jeff' Sipek 	INSTR(0xd, "bnhr",  IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
594*0472e113SJosef 'Jeff' Sipek 	INSTR(0xe, "bnor",  IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
595*0472e113SJosef 'Jeff' Sipek 	INSTR(0xf, "br",    IF_RR, F_370 | F_390 | F_Z | F_HIDE_MASK),
596*0472e113SJosef 'Jeff' Sipek };
597*0472e113SJosef 'Jeff' Sipek 
598*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_47[] = {
599*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0, "nop",   IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
600*0472e113SJosef 'Jeff' Sipek 	INSTR(0x1, "bo",    IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
601*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2, "bh",    IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
602*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3, "bc",    IF_RXb, F_370 | F_390 | F_Z),
603*0472e113SJosef 'Jeff' Sipek 	INSTR(0x4, "bl",    IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
604*0472e113SJosef 'Jeff' Sipek 	INSTR(0x5, "bc",    IF_RXb, F_370 | F_390 | F_Z),
605*0472e113SJosef 'Jeff' Sipek 	INSTR(0x6, "bc",    IF_RXb, F_370 | F_390 | F_Z),
606*0472e113SJosef 'Jeff' Sipek 	INSTR(0x7, "bne",   IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
607*0472e113SJosef 'Jeff' Sipek 	INSTR(0x8, "be",    IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
608*0472e113SJosef 'Jeff' Sipek 	INSTR(0x9, "bc",    IF_RXb, F_370 | F_390 | F_Z),
609*0472e113SJosef 'Jeff' Sipek 	INSTR(0xa, "bc",    IF_RXb, F_370 | F_390 | F_Z),
610*0472e113SJosef 'Jeff' Sipek 	INSTR(0xb, "bnl",   IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
611*0472e113SJosef 'Jeff' Sipek 	INSTR(0xc, "bc",    IF_RXb, F_370 | F_390 | F_Z),
612*0472e113SJosef 'Jeff' Sipek 	INSTR(0xd, "bnh",   IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
613*0472e113SJosef 'Jeff' Sipek 	INSTR(0xe, "bno",   IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
614*0472e113SJosef 'Jeff' Sipek 	INSTR(0xf, "b",     IF_RXb, F_370 | F_390 | F_Z | F_HIDE_MASK),
615*0472e113SJosef 'Jeff' Sipek };
616*0472e113SJosef 'Jeff' Sipek 
617*0472e113SJosef 'Jeff' Sipek /* the preferred mnemonic changed over time */
618*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_25[] = {
619*0472e113SJosef 'Jeff' Sipek 	INSTR(F_370, "lrdr",  IF_RR,   F_370),
620*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "ldxr",  IF_RR,   F_390),
621*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "ldxr",  IF_RR,   F_Z),
622*0472e113SJosef 'Jeff' Sipek };
623*0472e113SJosef 'Jeff' Sipek 
624*0472e113SJosef 'Jeff' Sipek /* the preferred mnemonic changed over time */
625*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_35[] = {
626*0472e113SJosef 'Jeff' Sipek 	INSTR(F_370, "lrer",  IF_RR,   F_370),
627*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "ledr",  IF_RR,   F_390),
628*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "ledr",  IF_RR,   F_Z),
629*0472e113SJosef 'Jeff' Sipek };
630*0472e113SJosef 'Jeff' Sipek 
631*0472e113SJosef 'Jeff' Sipek /* the preferred mnemonic changed over time */
632*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_3c[] = {
633*0472e113SJosef 'Jeff' Sipek 	INSTR(F_370, "mer",   IF_RR,   F_370),
634*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "mder",  IF_RR,   F_390),
635*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "mder",  IF_RR,   F_Z),
636*0472e113SJosef 'Jeff' Sipek };
637*0472e113SJosef 'Jeff' Sipek 
638*0472e113SJosef 'Jeff' Sipek /* the preferred mnemonic changed over time */
639*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_7c[] = {
640*0472e113SJosef 'Jeff' Sipek 	INSTR(F_370, "me",    IF_RXa,  F_370),
641*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "mde",   IF_RXa,  F_390),
642*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "mde",   IF_RXa,  F_Z),
643*0472e113SJosef 'Jeff' Sipek };
644*0472e113SJosef 'Jeff' Sipek 
645*0472e113SJosef 'Jeff' Sipek /* the meaning of this instruction changed over time */
646*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_84[] = {
647*0472e113SJosef 'Jeff' Sipek 	INSTR(F_370, "wrd",   IF_SI,   F_370),
648*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "brxh",  IF_RSI,  F_390),
649*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "brxh",  IF_RSI,  F_Z),
650*0472e113SJosef 'Jeff' Sipek };
651*0472e113SJosef 'Jeff' Sipek 
652*0472e113SJosef 'Jeff' Sipek /* the meaning of this instruction changed over time */
653*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_85[] = {
654*0472e113SJosef 'Jeff' Sipek 	INSTR(F_370, "rdd",   IF_SI,   F_370),
655*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "brxle", IF_RSI,  F_390),
656*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "brxle", IF_RSI,  F_Z),
657*0472e113SJosef 'Jeff' Sipek };
658*0472e113SJosef 'Jeff' Sipek 
659*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_a5x[16] = {
660*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0,  "iihh",  IF_RIa, F_Z),
661*0472e113SJosef 'Jeff' Sipek 	INSTR(0x1,  "iihl",  IF_RIa, F_Z),
662*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2,  "iilh",  IF_RIa, F_Z),
663*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3,  "iill",  IF_RIa, F_Z),
664*0472e113SJosef 'Jeff' Sipek 	INSTR(0x4,  "nihh",  IF_RIa, F_Z),
665*0472e113SJosef 'Jeff' Sipek 	INSTR(0x5,  "nihl",  IF_RIa, F_Z),
666*0472e113SJosef 'Jeff' Sipek 	INSTR(0x6,  "nilh",  IF_RIa, F_Z),
667*0472e113SJosef 'Jeff' Sipek 	INSTR(0x7,  "nill",  IF_RIa, F_Z),
668*0472e113SJosef 'Jeff' Sipek 	INSTR(0x8,  "oihh",  IF_RIa, F_Z),
669*0472e113SJosef 'Jeff' Sipek 	INSTR(0x9,  "oihl",  IF_RIa, F_Z),
670*0472e113SJosef 'Jeff' Sipek 	INSTR(0xa,  "oilh",  IF_RIa, F_Z),
671*0472e113SJosef 'Jeff' Sipek 	INSTR(0xb,  "oill",  IF_RIa, F_Z),
672*0472e113SJosef 'Jeff' Sipek 	INSTR(0xc,  "llihh", IF_RIa, F_Z),
673*0472e113SJosef 'Jeff' Sipek 	INSTR(0xd,  "llihl", IF_RIa, F_Z),
674*0472e113SJosef 'Jeff' Sipek 	INSTR(0xe,  "llilh", IF_RIa, F_Z),
675*0472e113SJosef 'Jeff' Sipek 	INSTR(0xf,  "llill", IF_RIa, F_Z),
676*0472e113SJosef 'Jeff' Sipek };
677*0472e113SJosef 'Jeff' Sipek 
678*0472e113SJosef 'Jeff' Sipek /* the preferred mnemonic changed over time */
679*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_a70[] = {
680*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "tmh",    IF_RIa, F_390),
681*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "tmlh",   IF_RIa, F_Z),
682*0472e113SJosef 'Jeff' Sipek };
683*0472e113SJosef 'Jeff' Sipek 
684*0472e113SJosef 'Jeff' Sipek /* the preferred mnemonic changed over time */
685*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_a71[] = {
686*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "tml",    IF_RIa, F_390),
687*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "tmll",   IF_RIa, F_Z),
688*0472e113SJosef 'Jeff' Sipek };
689*0472e113SJosef 'Jeff' Sipek 
690*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_a74[16] = {
691*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0, "jnop", IF_RIc, F_390 | F_Z | F_HIDE_MASK),
692*0472e113SJosef 'Jeff' Sipek 	INSTR(0x1, "jo",   IF_RIc, F_390 | F_Z | F_HIDE_MASK),
693*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2, "jh",   IF_RIc, F_390 | F_Z | F_HIDE_MASK),
694*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3, "brc",  IF_RIc, F_390 | F_Z),
695*0472e113SJosef 'Jeff' Sipek 	INSTR(0x4, "jl",   IF_RIc, F_390 | F_Z | F_HIDE_MASK),
696*0472e113SJosef 'Jeff' Sipek 	INSTR(0x5, "brc",  IF_RIc, F_390 | F_Z),
697*0472e113SJosef 'Jeff' Sipek 	INSTR(0x6, "brc",  IF_RIc, F_390 | F_Z),
698*0472e113SJosef 'Jeff' Sipek 	INSTR(0x7, "jne",  IF_RIc, F_390 | F_Z | F_HIDE_MASK),
699*0472e113SJosef 'Jeff' Sipek 	INSTR(0x8, "je",   IF_RIc, F_390 | F_Z | F_HIDE_MASK),
700*0472e113SJosef 'Jeff' Sipek 	INSTR(0x9, "brc",  IF_RIc, F_390 | F_Z),
701*0472e113SJosef 'Jeff' Sipek 	INSTR(0xa, "brc",  IF_RIc, F_390 | F_Z),
702*0472e113SJosef 'Jeff' Sipek 	INSTR(0xb, "jnl",  IF_RIc, F_390 | F_Z | F_HIDE_MASK),
703*0472e113SJosef 'Jeff' Sipek 	INSTR(0xc, "brc",  IF_RIc, F_390 | F_Z),
704*0472e113SJosef 'Jeff' Sipek 	INSTR(0xd, "jnh",  IF_RIc, F_390 | F_Z | F_HIDE_MASK),
705*0472e113SJosef 'Jeff' Sipek 	INSTR(0xe, "jno",  IF_RIc, F_390 | F_Z | F_HIDE_MASK),
706*0472e113SJosef 'Jeff' Sipek 	INSTR(0xf, "j",    IF_RIc, F_390 | F_Z | F_HIDE_MASK),
707*0472e113SJosef 'Jeff' Sipek };
708*0472e113SJosef 'Jeff' Sipek 
709*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_a7x[16] = {
710*0472e113SJosef 'Jeff' Sipek 	MULTI(0x0, tbl_a70),
711*0472e113SJosef 'Jeff' Sipek 	MULTI(0x1, tbl_a71),
712*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2, "tmhh",   IF_RIa, F_Z),
713*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3, "tmhl",   IF_RIa, F_Z),
714*0472e113SJosef 'Jeff' Sipek 	TABLE(0x4, tbl_a74, 1, 4, 0x0f),
715*0472e113SJosef 'Jeff' Sipek 	INSTR(0x5, "bras",   IF_RIb, F_390 | F_Z),
716*0472e113SJosef 'Jeff' Sipek 	INSTR(0x6, "brct",   IF_RIb, F_390 | F_Z),
717*0472e113SJosef 'Jeff' Sipek 	INSTR(0x7, "brctg",  IF_RIb, F_Z),
718*0472e113SJosef 'Jeff' Sipek 	INSTR(0x8, "lhi",    IF_RIa, F_390 | F_Z),
719*0472e113SJosef 'Jeff' Sipek 	INSTR(0x9, "lghi",   IF_RIa, F_Z),
720*0472e113SJosef 'Jeff' Sipek 	INSTR(0xa, "ahi",    IF_RIa, F_390 | F_Z | F_SIGNED_IMM),
721*0472e113SJosef 'Jeff' Sipek 	INSTR(0xb, "aghi",   IF_RIa, F_Z | F_SIGNED_IMM),
722*0472e113SJosef 'Jeff' Sipek 	INSTR(0xc, "mhi",    IF_RIa, F_390 | F_Z),
723*0472e113SJosef 'Jeff' Sipek 	INSTR(0xd, "mghi",   IF_RIa, F_Z),
724*0472e113SJosef 'Jeff' Sipek 	INSTR(0xe, "chi",    IF_RIa, F_390 | F_Z | F_SIGNED_IMM),
725*0472e113SJosef 'Jeff' Sipek 	INSTR(0xf, "cghi",   IF_RIa, F_Z | F_SIGNED_IMM),
726*0472e113SJosef 'Jeff' Sipek };
727*0472e113SJosef 'Jeff' Sipek 
728*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_b2a6[] = {
729*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "cuutf", IF_RRFc, F_390),
730*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "c21",   IF_RRFc, F_Z),
731*0472e113SJosef 'Jeff' Sipek };
732*0472e113SJosef 'Jeff' Sipek 
733*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_b2a7[] = {
734*0472e113SJosef 'Jeff' Sipek 	INSTR(F_390, "cutfu",  IF_RRFc, F_390),
735*0472e113SJosef 'Jeff' Sipek 	INSTR(F_Z,   "cu12",   IF_RRFc, F_Z),
736*0472e113SJosef 'Jeff' Sipek };
737*0472e113SJosef 'Jeff' Sipek 
738*0472e113SJosef 'Jeff' Sipek static const struct inst_table tbl_b2xx[256] = {
739*0472e113SJosef 'Jeff' Sipek 	INSTR(0x02, "stidp",  IF_S,    F_370 | F_390 | F_Z),
740*0472e113SJosef 'Jeff' Sipek 	INSTR(0x04, "sck",    IF_S,    F_370 | F_390 | F_Z),
741*0472e113SJosef 'Jeff' Sipek 	INSTR(0x05, "stck",   IF_S,    F_370 | F_390 | F_Z),
742*0472e113SJosef 'Jeff' Sipek 	INSTR(0x06, "sckc",   IF_S,    F_370 | F_390 | F_Z),
743*0472e113SJosef 'Jeff' Sipek 	INSTR(0x07, "stckc",  IF_S,    F_370 | F_390 | F_Z),
744*0472e113SJosef 'Jeff' Sipek 	INSTR(0x08, "spt",    IF_S,    F_370 | F_390 | F_Z),
745*0472e113SJosef 'Jeff' Sipek 	INSTR(0x09, "stpt",   IF_S,    F_370 | F_390 | F_Z),
746*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0a, "spka",   IF_S,    F_370 | F_390 | F_Z),
747*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0b, "ipk",    IF_S,    F_370 | F_390 | F_Z),
748*0472e113SJosef 'Jeff' Sipek 	INSTR(0x0d, "ptlb",   IF_S,    F_370 | F_390 | F_Z),
749*0472e113SJosef 'Jeff' Sipek 	INSTR(0x10, "spx",    IF_S,    F_370 | F_390 | F_Z),
750*0472e113SJosef 'Jeff' Sipek 	INSTR(0x11, "stpx",   IF_S,    F_370 | F_390 | F_Z),
751*0472e113SJosef 'Jeff' Sipek 	INSTR(0x12, "stap",   IF_S,    F_370 | F_390 | F_Z),
752*0472e113SJosef 'Jeff' Sipek 	INSTR(0x13, "rrb",    IF_S,    F_370),
753*0472e113SJosef 'Jeff' Sipek 	INSTR(0x14, "sie",    IF_S,    F_390 | F_Z),
754*0472e113SJosef 'Jeff' Sipek 	INSTR(0x18, "pc",     IF_S,    F_390 | F_Z),
755*0472e113SJosef 'Jeff' Sipek 	INSTR(0x19, "sac",    IF_S,    F_390 | F_Z),
756*0472e113SJosef 'Jeff' Sipek 	INSTR(0x1a, "cfc",    IF_S,    F_390 | F_Z),
757*0472e113SJosef 'Jeff' Sipek 	INSTR(0x21, "ipte",   IF_RRE,  F_390 | F_Z),
758*0472e113SJosef 'Jeff' Sipek 	INSTR(0x22, "ipm",    IF_RRE,  F_390 | F_Z),
759*0472e113SJosef 'Jeff' Sipek 	INSTR(0x23, "ivsk",   IF_RRE,  F_390 | F_Z),
760*0472e113SJosef 'Jeff' Sipek 	INSTR(0x24, "iac",    IF_RRE,  F_390 | F_Z),
761*0472e113SJosef 'Jeff' Sipek 	INSTR(0x25, "ssar",   IF_RRE,  F_390 | F_Z),
762*0472e113SJosef 'Jeff' Sipek 	INSTR(0x26, "epar",   IF_RRE,  F_390 | F_Z),
763*0472e113SJosef 'Jeff' Sipek 	INSTR(0x27, "esar",   IF_RRE,  F_390 | F_Z),
764*0472e113SJosef 'Jeff' Sipek 	INSTR(0x28, "pt",     IF_RRE,  F_390 | F_Z),
765*0472e113SJosef 'Jeff' Sipek 	INSTR(0x29, "iske",   IF_RRE,  F_390 | F_Z),
766*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2a, "rrbe",   IF_RRE,  F_390 | F_Z),
767*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2b, "sske",   IF_RRFc, F_390 | F_Z),
768*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2c, "tb",     IF_RRE,  F_390 | F_Z),
769*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2d, "dxr",    IF_RRE,  F_390 | F_Z),
770*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2e, "pgin",   IF_RRE,  F_390 | F_Z),
771*0472e113SJosef 'Jeff' Sipek 	INSTR(0x2f, "pgout",  IF_RRE,  F_390 | F_Z),
772*0472e113SJosef 'Jeff' Sipek 	INSTR(0x30, "csch",   IF_S,    F_Z),
773*0472e113SJosef 'Jeff' Sipek 	INSTR(0x31, "hsch",   IF_S,    F_Z),
774*0472e113SJosef 'Jeff' Sipek 	INSTR(0x32, "msch",   IF_S,    F_Z),
775*0472e113SJosef 'Jeff' Sipek 	INSTR(0x33, "ssch",   IF_S,    F_Z),
776*0472e113SJosef 'Jeff' Sipek 	INSTR(0x34, "stsch",  IF_S,    F_Z),
777*0472e113SJosef 'Jeff' Sipek 	INSTR(0x35, "tsch",   IF_S,    F_Z),
778*0472e113SJosef 'Jeff' Sipek 	INSTR(0x36, "tpi",    IF_S,    F_Z),
779*0472e113SJosef 'Jeff' Sipek 	INSTR(0x37, "sal",    IF_S,    F_Z),
780*0472e113SJosef 'Jeff' Sipek 	INSTR(0x38, "rsch",   IF_S,    F_Z),
781*0472e113SJosef 'Jeff' Sipek 	INSTR(0x39, "stcrw",  IF_S,    F_Z),
782*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3a, "stcps",  IF_S,    F_Z),
783*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3b, "rchp",   IF_S,    F_Z),
784*0472e113SJosef 'Jeff' Sipek 	INSTR(0x3d, "schm",   IF_S,    F_Z),