175fd0b74Schristos /* mmix.h -- Header file for MMIX opcode table 2*e992f068Schristos Copyright (C) 2001-2022 Free Software Foundation, Inc. 375fd0b74Schristos Written by Hans-Peter Nilsson (hp@bitrange.com) 475fd0b74Schristos 575fd0b74Schristos This file is part of GDB, GAS, and the GNU binutils. 675fd0b74Schristos 775fd0b74Schristos GDB, GAS, and the GNU binutils are free software; you can redistribute 875fd0b74Schristos them and/or modify them under the terms of the GNU General Public 975fd0b74Schristos License as published by the Free Software Foundation; either version 3, 1075fd0b74Schristos or (at your option) any later version. 1175fd0b74Schristos 1275fd0b74Schristos GDB, GAS, and the GNU binutils are distributed in the hope that they 1375fd0b74Schristos will be useful, but WITHOUT ANY WARRANTY; without even the implied 1475fd0b74Schristos warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 1575fd0b74Schristos the GNU General Public License for more details. 1675fd0b74Schristos 1775fd0b74Schristos You should have received a copy of the GNU General Public License 1875fd0b74Schristos along with this file; see the file COPYING3. If not, write to the Free 1975fd0b74Schristos Software Foundation, 51 Franklin Street - Fifth Floor, Boston, 2075fd0b74Schristos MA 02110-1301, USA. */ 2175fd0b74Schristos 2275fd0b74Schristos /* We could have just a char*[] table indexed by the register number, but 2375fd0b74Schristos that would not allow for synonyms. The table is terminated with an 2475fd0b74Schristos entry with a NULL name. */ 2575fd0b74Schristos struct mmix_spec_reg 2675fd0b74Schristos { 2775fd0b74Schristos const char *name; 2875fd0b74Schristos unsigned int number; 2975fd0b74Schristos }; 3075fd0b74Schristos 3175fd0b74Schristos /* General indication of the type of instruction. */ 3275fd0b74Schristos enum mmix_insn_type 3375fd0b74Schristos { 3475fd0b74Schristos mmix_type_pseudo, 3575fd0b74Schristos mmix_type_normal, 3675fd0b74Schristos mmix_type_branch, 3775fd0b74Schristos mmix_type_condbranch, 3875fd0b74Schristos mmix_type_memaccess_octa, 3975fd0b74Schristos mmix_type_memaccess_tetra, 4075fd0b74Schristos mmix_type_memaccess_wyde, 4175fd0b74Schristos mmix_type_memaccess_byte, 4275fd0b74Schristos mmix_type_memaccess_block, 4375fd0b74Schristos mmix_type_jsr 4475fd0b74Schristos }; 4575fd0b74Schristos 4675fd0b74Schristos /* Type of operands an instruction takes. Use when parsing assembly code 4775fd0b74Schristos and disassembling. */ 4875fd0b74Schristos enum mmix_operands_type 4975fd0b74Schristos { 5075fd0b74Schristos mmix_operands_none = 0, 5175fd0b74Schristos 5275fd0b74Schristos /* All operands are registers: "$X,$Y,$Z". */ 5375fd0b74Schristos mmix_operands_regs, 5475fd0b74Schristos 5575fd0b74Schristos /* "$X,YZ", like SETH. */ 5675fd0b74Schristos mmix_operands_reg_yz, 5775fd0b74Schristos 5875fd0b74Schristos /* The regular "$X,$Y,$Z|Z". 5975fd0b74Schristos The Z is optional; if only "$X,$Y" is given, then "$X,$Y,0" is 6075fd0b74Schristos assumed. */ 6175fd0b74Schristos mmix_operands_regs_z_opt, 6275fd0b74Schristos 6375fd0b74Schristos /* The regular "$X,$Y,$Z|Z". */ 6475fd0b74Schristos mmix_operands_regs_z, 6575fd0b74Schristos 6675fd0b74Schristos /* "Address"; only JMP. Zero operands allowed unless GNU syntax. */ 6775fd0b74Schristos mmix_operands_jmp, 6875fd0b74Schristos 6975fd0b74Schristos /* "$X|X,$Y,$Z|Z": PUSHGO; like "3", but X can be expressed as an 7075fd0b74Schristos integer. */ 7175fd0b74Schristos mmix_operands_pushgo, 7275fd0b74Schristos 7375fd0b74Schristos /* Two registers or a register and a byte, like FLOT, possibly with 7475fd0b74Schristos rounding: "$X,$Z|Z" or "$X,ROUND_MODE,$Z|Z". */ 7575fd0b74Schristos mmix_operands_roundregs_z, 7675fd0b74Schristos 7775fd0b74Schristos /* "X,YZ", POP. Unless GNU syntax, zero or one operand is allowed. */ 7875fd0b74Schristos mmix_operands_pop, 7975fd0b74Schristos 8075fd0b74Schristos /* Two registers, possibly with rounding: "$X,$Z" or 8175fd0b74Schristos "$X,ROUND_MODE,$Z". */ 8275fd0b74Schristos mmix_operands_roundregs, 8375fd0b74Schristos 8475fd0b74Schristos /* "XYZ", like SYNC. */ 8575fd0b74Schristos mmix_operands_sync, 8675fd0b74Schristos 8775fd0b74Schristos /* "X,$Y,$Z|Z", like SYNCD. */ 8875fd0b74Schristos mmix_operands_x_regs_z, 8975fd0b74Schristos 9075fd0b74Schristos /* "$X,Y,$Z|Z", like NEG and NEGU. The Y field is optional, default 0. */ 9175fd0b74Schristos mmix_operands_neg, 9275fd0b74Schristos 9375fd0b74Schristos /* "$X,Address, like GETA or branches. */ 9475fd0b74Schristos mmix_operands_regaddr, 9575fd0b74Schristos 9675fd0b74Schristos /* "$X|X,Address, like PUSHJ. */ 9775fd0b74Schristos mmix_operands_pushj, 9875fd0b74Schristos 9975fd0b74Schristos /* "$X,spec_reg"; GET. */ 10075fd0b74Schristos mmix_operands_get, 10175fd0b74Schristos 10275fd0b74Schristos /* "spec_reg,$Z|Z"; PUT. */ 10375fd0b74Schristos mmix_operands_put, 10475fd0b74Schristos 10575fd0b74Schristos /* Two registers, "$X,$Y". */ 10675fd0b74Schristos mmix_operands_set, 10775fd0b74Schristos 10875fd0b74Schristos /* "$X,0"; SAVE. */ 10975fd0b74Schristos mmix_operands_save, 11075fd0b74Schristos 11175fd0b74Schristos /* "0,$Z"; UNSAVE. */ 11275fd0b74Schristos mmix_operands_unsave, 11375fd0b74Schristos 11475fd0b74Schristos /* "X,Y,Z"; like SWYM or TRAP. Zero (or 1 if GNU syntax) to three 11575fd0b74Schristos operands, interpreted as 0; XYZ; X, YZ and X, Y, Z. */ 11675fd0b74Schristos mmix_operands_xyz_opt, 11775fd0b74Schristos 11875fd0b74Schristos /* Just "Z", like RESUME. Unless GNU syntax, the operand can be omitted 11975fd0b74Schristos and will then be assumed zero. */ 12075fd0b74Schristos mmix_operands_resume, 12175fd0b74Schristos 12275fd0b74Schristos /* These are specials to handle that pseudo-directives are specified 12375fd0b74Schristos like ordinary insns when being mmixal-compatible. They signify the 12475fd0b74Schristos specific pseudo-directive rather than the operands type. */ 12575fd0b74Schristos 12675fd0b74Schristos /* LOC. */ 12775fd0b74Schristos mmix_operands_loc, 12875fd0b74Schristos 12975fd0b74Schristos /* PREFIX. */ 13075fd0b74Schristos mmix_operands_prefix, 13175fd0b74Schristos 13275fd0b74Schristos /* BYTE. */ 13375fd0b74Schristos mmix_operands_byte, 13475fd0b74Schristos 13575fd0b74Schristos /* WYDE. */ 13675fd0b74Schristos mmix_operands_wyde, 13775fd0b74Schristos 13875fd0b74Schristos /* TETRA. */ 13975fd0b74Schristos mmix_operands_tetra, 14075fd0b74Schristos 14175fd0b74Schristos /* OCTA. */ 14275fd0b74Schristos mmix_operands_octa, 14375fd0b74Schristos 14475fd0b74Schristos /* LOCAL. */ 14575fd0b74Schristos mmix_operands_local, 14675fd0b74Schristos 14775fd0b74Schristos /* BSPEC. */ 14875fd0b74Schristos mmix_operands_bspec, 14975fd0b74Schristos 15075fd0b74Schristos /* ESPEC. */ 15175fd0b74Schristos mmix_operands_espec, 15275fd0b74Schristos }; 15375fd0b74Schristos 15475fd0b74Schristos struct mmix_opcode 15575fd0b74Schristos { 15675fd0b74Schristos const char *name; 15775fd0b74Schristos unsigned long match; 15875fd0b74Schristos unsigned long lose; 15975fd0b74Schristos enum mmix_operands_type operands; 16075fd0b74Schristos 16175fd0b74Schristos /* This is used by the disassembly function. */ 16275fd0b74Schristos enum mmix_insn_type type; 16375fd0b74Schristos }; 16475fd0b74Schristos 16575fd0b74Schristos /* Declare the actual tables. */ 16675fd0b74Schristos extern const struct mmix_opcode mmix_opcodes[]; 16775fd0b74Schristos 16875fd0b74Schristos /* This one is terminated with an entry with a NULL name. */ 16975fd0b74Schristos extern const struct mmix_spec_reg mmix_spec_regs[]; 17075fd0b74Schristos 17175fd0b74Schristos /* Some insn values we use when padding and synthesizing address loads. */ 17275fd0b74Schristos #define IMM_OFFSET_BIT 1 17375fd0b74Schristos #define COND_INV_BIT 0x8 17475fd0b74Schristos #define PRED_INV_BIT 0x10 17575fd0b74Schristos 176012573ebSchristos #define PUSHGO_INSN_BYTE 0xbeu 177012573ebSchristos #define GO_INSN_BYTE 0x9eu 178012573ebSchristos #define SETL_INSN_BYTE 0xe3u 179012573ebSchristos #define INCML_INSN_BYTE 0xe6u 180012573ebSchristos #define INCMH_INSN_BYTE 0xe5u 181012573ebSchristos #define INCH_INSN_BYTE 0xe4u 182012573ebSchristos #define SWYM_INSN_BYTE 0xfdu 183012573ebSchristos #define JMP_INSN_BYTE 0xf0u 18475fd0b74Schristos 18575fd0b74Schristos /* We can have 256 - 32 (local registers) - 1 ($255 is not allocatable) 18675fd0b74Schristos global registers. */ 18775fd0b74Schristos #define MAX_GREGS 223 188