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