xref: /openbsd-src/gnu/usr.bin/binutils/include/opcode/mmix.h (revision cf2f2c5620d6d9a4fd01930983c4b9a1f76d7aa3)
1d2201f2fSdrahn /* mmix.h -- Header file for MMIX opcode table
2*cf2f2c56Smiod    Copyright (C) 2001, 2003 Free Software Foundation, Inc.
3d2201f2fSdrahn    Written by Hans-Peter Nilsson (hp@bitrange.com)
4d2201f2fSdrahn 
5d2201f2fSdrahn This file is part of GDB, GAS, and the GNU binutils.
6d2201f2fSdrahn 
7d2201f2fSdrahn GDB, GAS, and the GNU binutils are free software; you can redistribute
8d2201f2fSdrahn them and/or modify them under the terms of the GNU General Public
9d2201f2fSdrahn License as published by the Free Software Foundation; either version 2,
10d2201f2fSdrahn or (at your option) any later version.
11d2201f2fSdrahn 
12d2201f2fSdrahn GDB, GAS, and the GNU binutils are distributed in the hope that they
13d2201f2fSdrahn will be useful, but WITHOUT ANY WARRANTY; without even the implied
14d2201f2fSdrahn warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
15d2201f2fSdrahn the GNU General Public License for more details.
16d2201f2fSdrahn 
17d2201f2fSdrahn You should have received a copy of the GNU General Public License
18d2201f2fSdrahn along with this file; see the file COPYING.  If not, write to the Free
19d2201f2fSdrahn Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20d2201f2fSdrahn 
21d2201f2fSdrahn /* We could have just a char*[] table indexed by the register number, but
22d2201f2fSdrahn    that would not allow for synonyms.  The table is terminated with an
23d2201f2fSdrahn    entry with a NULL name.  */
24d2201f2fSdrahn struct mmix_spec_reg
25d2201f2fSdrahn {
26d2201f2fSdrahn   const char *name;
27d2201f2fSdrahn   unsigned int number;
28d2201f2fSdrahn };
29d2201f2fSdrahn 
30d2201f2fSdrahn /* General indication of the type of instruction.  */
31d2201f2fSdrahn enum mmix_insn_type
32d2201f2fSdrahn  {
33d2201f2fSdrahn    mmix_type_pseudo,
34d2201f2fSdrahn    mmix_type_normal,
35d2201f2fSdrahn    mmix_type_branch,
36d2201f2fSdrahn    mmix_type_condbranch,
37d2201f2fSdrahn    mmix_type_memaccess_octa,
38d2201f2fSdrahn    mmix_type_memaccess_tetra,
39d2201f2fSdrahn    mmix_type_memaccess_wyde,
40d2201f2fSdrahn    mmix_type_memaccess_byte,
41d2201f2fSdrahn    mmix_type_memaccess_block,
42d2201f2fSdrahn    mmix_type_jsr
43d2201f2fSdrahn  };
44d2201f2fSdrahn 
45d2201f2fSdrahn /* Type of operands an instruction takes.  Use when parsing assembly code
46d2201f2fSdrahn    and disassembling.  */
47d2201f2fSdrahn enum mmix_operands_type
48d2201f2fSdrahn  {
49d2201f2fSdrahn    mmix_operands_none = 0,
50d2201f2fSdrahn 
51d2201f2fSdrahn    /* All operands are registers: "$X,$Y,$Z".  */
52d2201f2fSdrahn    mmix_operands_regs,
53d2201f2fSdrahn 
54d2201f2fSdrahn    /* "$X,YZ", like SETH.  */
55d2201f2fSdrahn    mmix_operands_reg_yz,
56d2201f2fSdrahn 
57d2201f2fSdrahn    /* The regular "$X,$Y,$Z|Z".
58d2201f2fSdrahn       The Z is optional; if only "$X,$Y" is given, then "$X,$Y,0" is
59d2201f2fSdrahn       assumed.  */
60d2201f2fSdrahn    mmix_operands_regs_z_opt,
61d2201f2fSdrahn 
62d2201f2fSdrahn    /* The regular "$X,$Y,$Z|Z".  */
63d2201f2fSdrahn    mmix_operands_regs_z,
64d2201f2fSdrahn 
65d2201f2fSdrahn    /* "Address"; only JMP.  Zero operands allowed unless GNU syntax.  */
66d2201f2fSdrahn    mmix_operands_jmp,
67d2201f2fSdrahn 
68d2201f2fSdrahn    /* "$X|X,$Y,$Z|Z": PUSHGO; like "3", but X can be expressed as an
69d2201f2fSdrahn       integer.  */
70d2201f2fSdrahn    mmix_operands_pushgo,
71d2201f2fSdrahn 
72d2201f2fSdrahn    /* Two registers or a register and a byte, like FLOT, possibly with
73d2201f2fSdrahn       rounding: "$X,$Z|Z" or "$X,ROUND_MODE,$Z|Z".  */
74d2201f2fSdrahn    mmix_operands_roundregs_z,
75d2201f2fSdrahn 
76d2201f2fSdrahn    /* "X,YZ", POP.  Unless GNU syntax, zero or one operand is allowed.  */
77d2201f2fSdrahn    mmix_operands_pop,
78d2201f2fSdrahn 
79d2201f2fSdrahn    /* Two registers, possibly with rounding: "$X,$Z" or
80d2201f2fSdrahn       "$X,ROUND_MODE,$Z".  */
81d2201f2fSdrahn    mmix_operands_roundregs,
82d2201f2fSdrahn 
83d2201f2fSdrahn    /* "XYZ", like SYNC.  */
84d2201f2fSdrahn    mmix_operands_sync,
85d2201f2fSdrahn 
86d2201f2fSdrahn    /* "X,$Y,$Z|Z", like SYNCD.  */
87d2201f2fSdrahn    mmix_operands_x_regs_z,
88d2201f2fSdrahn 
89d2201f2fSdrahn    /* "$X,Y,$Z|Z", like NEG and NEGU.  The Y field is optional, default 0.  */
90d2201f2fSdrahn    mmix_operands_neg,
91d2201f2fSdrahn 
92d2201f2fSdrahn    /* "$X,Address, like GETA or branches.  */
93d2201f2fSdrahn    mmix_operands_regaddr,
94d2201f2fSdrahn 
95d2201f2fSdrahn    /* "$X|X,Address, like PUSHJ.  */
96d2201f2fSdrahn    mmix_operands_pushj,
97d2201f2fSdrahn 
98d2201f2fSdrahn    /* "$X,spec_reg"; GET.  */
99d2201f2fSdrahn    mmix_operands_get,
100d2201f2fSdrahn 
101d2201f2fSdrahn    /* "spec_reg,$Z|Z"; PUT.  */
102d2201f2fSdrahn    mmix_operands_put,
103d2201f2fSdrahn 
104d2201f2fSdrahn    /* Two registers, "$X,$Y".  */
105d2201f2fSdrahn    mmix_operands_set,
106d2201f2fSdrahn 
107d2201f2fSdrahn    /* "$X,0"; SAVE.  */
108d2201f2fSdrahn    mmix_operands_save,
109d2201f2fSdrahn 
110d2201f2fSdrahn    /* "0,$Z"; UNSAVE. */
111d2201f2fSdrahn    mmix_operands_unsave,
112d2201f2fSdrahn 
113d2201f2fSdrahn    /* "X,Y,Z"; like SWYM or TRAP.  Zero (or 1 if GNU syntax) to three
114d2201f2fSdrahn       operands, interpreted as 0; XYZ; X, YZ and X, Y, Z.  */
115d2201f2fSdrahn    mmix_operands_xyz_opt,
116d2201f2fSdrahn 
117d2201f2fSdrahn    /* Just "Z", like RESUME.  Unless GNU syntax, the operand can be omitted
118d2201f2fSdrahn       and will then be assumed zero.  */
119d2201f2fSdrahn    mmix_operands_resume,
120d2201f2fSdrahn 
121d2201f2fSdrahn    /* These are specials to handle that pseudo-directives are specified
122d2201f2fSdrahn       like ordinary insns when being mmixal-compatible.  They signify the
123d2201f2fSdrahn       specific pseudo-directive rather than the operands type.  */
124d2201f2fSdrahn 
125d2201f2fSdrahn    /* LOC.  */
126d2201f2fSdrahn    mmix_operands_loc,
127d2201f2fSdrahn 
128d2201f2fSdrahn    /* PREFIX.  */
129d2201f2fSdrahn    mmix_operands_prefix,
130d2201f2fSdrahn 
131d2201f2fSdrahn    /* BYTE.  */
132d2201f2fSdrahn    mmix_operands_byte,
133d2201f2fSdrahn 
134d2201f2fSdrahn    /* WYDE.  */
135d2201f2fSdrahn    mmix_operands_wyde,
136d2201f2fSdrahn 
137d2201f2fSdrahn    /* TETRA.  */
138d2201f2fSdrahn    mmix_operands_tetra,
139d2201f2fSdrahn 
140d2201f2fSdrahn    /* OCTA.  */
141d2201f2fSdrahn    mmix_operands_octa,
142d2201f2fSdrahn 
143d2201f2fSdrahn    /* LOCAL.  */
144d2201f2fSdrahn    mmix_operands_local,
145d2201f2fSdrahn 
146d2201f2fSdrahn    /* BSPEC.  */
147d2201f2fSdrahn    mmix_operands_bspec,
148d2201f2fSdrahn 
149d2201f2fSdrahn    /* ESPEC.  */
150d2201f2fSdrahn    mmix_operands_espec,
151d2201f2fSdrahn  };
152d2201f2fSdrahn 
153d2201f2fSdrahn struct mmix_opcode
154d2201f2fSdrahn  {
155d2201f2fSdrahn    const char *name;
156d2201f2fSdrahn    unsigned long match;
157d2201f2fSdrahn    unsigned long lose;
158d2201f2fSdrahn    enum mmix_operands_type operands;
159d2201f2fSdrahn 
160d2201f2fSdrahn    /* This is used by the disassembly function.  */
161d2201f2fSdrahn    enum mmix_insn_type type;
162d2201f2fSdrahn  };
163d2201f2fSdrahn 
164d2201f2fSdrahn /* Declare the actual tables.  */
165d2201f2fSdrahn extern const struct mmix_opcode mmix_opcodes[];
166d2201f2fSdrahn 
167d2201f2fSdrahn /* This one is terminated with an entry with a NULL name.  */
168d2201f2fSdrahn extern const struct mmix_spec_reg mmix_spec_regs[];
169d2201f2fSdrahn 
170d2201f2fSdrahn /* Some insn values we use when padding and synthesizing address loads.  */
171d2201f2fSdrahn #define IMM_OFFSET_BIT 1
172d2201f2fSdrahn #define COND_INV_BIT 0x8
173d2201f2fSdrahn #define PRED_INV_BIT 0x10
174d2201f2fSdrahn 
175d2201f2fSdrahn #define PUSHGO_INSN_BYTE 0xbe
176d2201f2fSdrahn #define GO_INSN_BYTE 0x9e
177d2201f2fSdrahn #define SETL_INSN_BYTE 0xe3
178d2201f2fSdrahn #define INCML_INSN_BYTE 0xe6
179d2201f2fSdrahn #define INCMH_INSN_BYTE 0xe5
180d2201f2fSdrahn #define INCH_INSN_BYTE 0xe4
181d2201f2fSdrahn #define SWYM_INSN_BYTE 0xfd
182*cf2f2c56Smiod #define JMP_INSN_BYTE 0xf0
183d2201f2fSdrahn 
184d2201f2fSdrahn /* We can have 256 - 32 (local registers) - 1 ($255 is not allocatable)
185d2201f2fSdrahn    global registers.  */
186d2201f2fSdrahn #define MAX_GREGS 223
187