198b9484cSchristos /* mmix.h -- Header file for MMIX opcode table 2*aab831ceSchristos Copyright (C) 2001-2024 Free Software Foundation, Inc. 398b9484cSchristos Written by Hans-Peter Nilsson (hp@bitrange.com) 498b9484cSchristos 598b9484cSchristos This file is part of GDB, GAS, and the GNU binutils. 698b9484cSchristos 798b9484cSchristos GDB, GAS, and the GNU binutils are free software; you can redistribute 898b9484cSchristos them and/or modify them under the terms of the GNU General Public 998b9484cSchristos License as published by the Free Software Foundation; either version 3, 1098b9484cSchristos or (at your option) any later version. 1198b9484cSchristos 1298b9484cSchristos GDB, GAS, and the GNU binutils are distributed in the hope that they 1398b9484cSchristos will be useful, but WITHOUT ANY WARRANTY; without even the implied 1498b9484cSchristos warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 1598b9484cSchristos the GNU General Public License for more details. 1698b9484cSchristos 1798b9484cSchristos You should have received a copy of the GNU General Public License 1898b9484cSchristos along with this file; see the file COPYING3. If not, write to the Free 1998b9484cSchristos Software Foundation, 51 Franklin Street - Fifth Floor, Boston, 2098b9484cSchristos MA 02110-1301, USA. */ 2198b9484cSchristos 2298b9484cSchristos /* We could have just a char*[] table indexed by the register number, but 2398b9484cSchristos that would not allow for synonyms. The table is terminated with an 2498b9484cSchristos entry with a NULL name. */ 2598b9484cSchristos struct mmix_spec_reg 2698b9484cSchristos { 2798b9484cSchristos const char *name; 2898b9484cSchristos unsigned int number; 2998b9484cSchristos }; 3098b9484cSchristos 3198b9484cSchristos /* General indication of the type of instruction. */ 3298b9484cSchristos enum mmix_insn_type 3398b9484cSchristos { 3498b9484cSchristos mmix_type_pseudo, 3598b9484cSchristos mmix_type_normal, 3698b9484cSchristos mmix_type_branch, 3798b9484cSchristos mmix_type_condbranch, 3898b9484cSchristos mmix_type_memaccess_octa, 3998b9484cSchristos mmix_type_memaccess_tetra, 4098b9484cSchristos mmix_type_memaccess_wyde, 4198b9484cSchristos mmix_type_memaccess_byte, 4298b9484cSchristos mmix_type_memaccess_block, 4398b9484cSchristos mmix_type_jsr 4498b9484cSchristos }; 4598b9484cSchristos 4698b9484cSchristos /* Type of operands an instruction takes. Use when parsing assembly code 4798b9484cSchristos and disassembling. */ 4898b9484cSchristos enum mmix_operands_type 4998b9484cSchristos { 5098b9484cSchristos mmix_operands_none = 0, 5198b9484cSchristos 5298b9484cSchristos /* All operands are registers: "$X,$Y,$Z". */ 5398b9484cSchristos mmix_operands_regs, 5498b9484cSchristos 5598b9484cSchristos /* "$X,YZ", like SETH. */ 5698b9484cSchristos mmix_operands_reg_yz, 5798b9484cSchristos 5898b9484cSchristos /* The regular "$X,$Y,$Z|Z". 5998b9484cSchristos The Z is optional; if only "$X,$Y" is given, then "$X,$Y,0" is 6098b9484cSchristos assumed. */ 6198b9484cSchristos mmix_operands_regs_z_opt, 6298b9484cSchristos 6398b9484cSchristos /* The regular "$X,$Y,$Z|Z". */ 6498b9484cSchristos mmix_operands_regs_z, 6598b9484cSchristos 6698b9484cSchristos /* "Address"; only JMP. Zero operands allowed unless GNU syntax. */ 6798b9484cSchristos mmix_operands_jmp, 6898b9484cSchristos 6998b9484cSchristos /* "$X|X,$Y,$Z|Z": PUSHGO; like "3", but X can be expressed as an 7098b9484cSchristos integer. */ 7198b9484cSchristos mmix_operands_pushgo, 7298b9484cSchristos 7398b9484cSchristos /* Two registers or a register and a byte, like FLOT, possibly with 7498b9484cSchristos rounding: "$X,$Z|Z" or "$X,ROUND_MODE,$Z|Z". */ 7598b9484cSchristos mmix_operands_roundregs_z, 7698b9484cSchristos 7798b9484cSchristos /* "X,YZ", POP. Unless GNU syntax, zero or one operand is allowed. */ 7898b9484cSchristos mmix_operands_pop, 7998b9484cSchristos 8098b9484cSchristos /* Two registers, possibly with rounding: "$X,$Z" or 8198b9484cSchristos "$X,ROUND_MODE,$Z". */ 8298b9484cSchristos mmix_operands_roundregs, 8398b9484cSchristos 8498b9484cSchristos /* "XYZ", like SYNC. */ 8598b9484cSchristos mmix_operands_sync, 8698b9484cSchristos 8798b9484cSchristos /* "X,$Y,$Z|Z", like SYNCD. */ 8898b9484cSchristos mmix_operands_x_regs_z, 8998b9484cSchristos 9098b9484cSchristos /* "$X,Y,$Z|Z", like NEG and NEGU. The Y field is optional, default 0. */ 9198b9484cSchristos mmix_operands_neg, 9298b9484cSchristos 9398b9484cSchristos /* "$X,Address, like GETA or branches. */ 9498b9484cSchristos mmix_operands_regaddr, 9598b9484cSchristos 9698b9484cSchristos /* "$X|X,Address, like PUSHJ. */ 9798b9484cSchristos mmix_operands_pushj, 9898b9484cSchristos 9998b9484cSchristos /* "$X,spec_reg"; GET. */ 10098b9484cSchristos mmix_operands_get, 10198b9484cSchristos 10298b9484cSchristos /* "spec_reg,$Z|Z"; PUT. */ 10398b9484cSchristos mmix_operands_put, 10498b9484cSchristos 10598b9484cSchristos /* Two registers, "$X,$Y". */ 10698b9484cSchristos mmix_operands_set, 10798b9484cSchristos 10898b9484cSchristos /* "$X,0"; SAVE. */ 10998b9484cSchristos mmix_operands_save, 11098b9484cSchristos 11198b9484cSchristos /* "0,$Z"; UNSAVE. */ 11298b9484cSchristos mmix_operands_unsave, 11398b9484cSchristos 11498b9484cSchristos /* "X,Y,Z"; like SWYM or TRAP. Zero (or 1 if GNU syntax) to three 11598b9484cSchristos operands, interpreted as 0; XYZ; X, YZ and X, Y, Z. */ 11698b9484cSchristos mmix_operands_xyz_opt, 11798b9484cSchristos 11898b9484cSchristos /* Just "Z", like RESUME. Unless GNU syntax, the operand can be omitted 11998b9484cSchristos and will then be assumed zero. */ 12098b9484cSchristos mmix_operands_resume, 12198b9484cSchristos 12298b9484cSchristos /* These are specials to handle that pseudo-directives are specified 12398b9484cSchristos like ordinary insns when being mmixal-compatible. They signify the 12498b9484cSchristos specific pseudo-directive rather than the operands type. */ 12598b9484cSchristos 12698b9484cSchristos /* LOC. */ 12798b9484cSchristos mmix_operands_loc, 12898b9484cSchristos 12998b9484cSchristos /* PREFIX. */ 13098b9484cSchristos mmix_operands_prefix, 13198b9484cSchristos 13298b9484cSchristos /* BYTE. */ 13398b9484cSchristos mmix_operands_byte, 13498b9484cSchristos 13598b9484cSchristos /* WYDE. */ 13698b9484cSchristos mmix_operands_wyde, 13798b9484cSchristos 13898b9484cSchristos /* TETRA. */ 13998b9484cSchristos mmix_operands_tetra, 14098b9484cSchristos 14198b9484cSchristos /* OCTA. */ 14298b9484cSchristos mmix_operands_octa, 14398b9484cSchristos 14498b9484cSchristos /* LOCAL. */ 14598b9484cSchristos mmix_operands_local, 14698b9484cSchristos 14798b9484cSchristos /* BSPEC. */ 14898b9484cSchristos mmix_operands_bspec, 14998b9484cSchristos 15098b9484cSchristos /* ESPEC. */ 15198b9484cSchristos mmix_operands_espec, 15298b9484cSchristos }; 15398b9484cSchristos 15498b9484cSchristos struct mmix_opcode 15598b9484cSchristos { 15698b9484cSchristos const char *name; 15798b9484cSchristos unsigned long match; 15898b9484cSchristos unsigned long lose; 15998b9484cSchristos enum mmix_operands_type operands; 16098b9484cSchristos 16198b9484cSchristos /* This is used by the disassembly function. */ 16298b9484cSchristos enum mmix_insn_type type; 16398b9484cSchristos }; 16498b9484cSchristos 16598b9484cSchristos /* Declare the actual tables. */ 16698b9484cSchristos extern const struct mmix_opcode mmix_opcodes[]; 16798b9484cSchristos 16898b9484cSchristos /* This one is terminated with an entry with a NULL name. */ 16998b9484cSchristos extern const struct mmix_spec_reg mmix_spec_regs[]; 17098b9484cSchristos 17198b9484cSchristos /* Some insn values we use when padding and synthesizing address loads. */ 17298b9484cSchristos #define IMM_OFFSET_BIT 1 17398b9484cSchristos #define COND_INV_BIT 0x8 17498b9484cSchristos #define PRED_INV_BIT 0x10 17598b9484cSchristos 1768dffb485Schristos #define PUSHGO_INSN_BYTE 0xbeu 1778dffb485Schristos #define GO_INSN_BYTE 0x9eu 1788dffb485Schristos #define SETL_INSN_BYTE 0xe3u 1798dffb485Schristos #define INCML_INSN_BYTE 0xe6u 1808dffb485Schristos #define INCMH_INSN_BYTE 0xe5u 1818dffb485Schristos #define INCH_INSN_BYTE 0xe4u 1828dffb485Schristos #define SWYM_INSN_BYTE 0xfdu 1838dffb485Schristos #define JMP_INSN_BYTE 0xf0u 18498b9484cSchristos 18598b9484cSchristos /* We can have 256 - 32 (local registers) - 1 ($255 is not allocatable) 18698b9484cSchristos global registers. */ 18798b9484cSchristos #define MAX_GREGS 223 188