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