Back to index

cell-binutils  2.17cvs20070401
mmix.h
Go to the documentation of this file.
00001 /* mmix.h -- Header file for MMIX opcode table
00002    Copyright (C) 2001, 2003 Free Software Foundation, Inc.
00003    Written by Hans-Peter Nilsson (hp@bitrange.com)
00004 
00005 This file is part of GDB, GAS, and the GNU binutils.
00006 
00007 GDB, GAS, and the GNU binutils are free software; you can redistribute
00008 them and/or modify them under the terms of the GNU General Public
00009 License as published by the Free Software Foundation; either version 2,
00010 or (at your option) any later version.
00011 
00012 GDB, GAS, and the GNU binutils are distributed in the hope that they
00013 will be useful, but WITHOUT ANY WARRANTY; without even the implied
00014 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
00015 the GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this file; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 /* We could have just a char*[] table indexed by the register number, but
00022    that would not allow for synonyms.  The table is terminated with an
00023    entry with a NULL name.  */
00024 struct mmix_spec_reg
00025 {
00026   const char *name;
00027   unsigned int number;
00028 };
00029 
00030 /* General indication of the type of instruction.  */
00031 enum mmix_insn_type
00032  {
00033    mmix_type_pseudo,
00034    mmix_type_normal,
00035    mmix_type_branch,
00036    mmix_type_condbranch,
00037    mmix_type_memaccess_octa,
00038    mmix_type_memaccess_tetra,
00039    mmix_type_memaccess_wyde,
00040    mmix_type_memaccess_byte,
00041    mmix_type_memaccess_block,
00042    mmix_type_jsr
00043  };
00044 
00045 /* Type of operands an instruction takes.  Use when parsing assembly code
00046    and disassembling.  */
00047 enum mmix_operands_type
00048  {
00049    mmix_operands_none = 0,
00050 
00051    /* All operands are registers: "$X,$Y,$Z".  */
00052    mmix_operands_regs,
00053 
00054    /* "$X,YZ", like SETH.  */
00055    mmix_operands_reg_yz,
00056 
00057    /* The regular "$X,$Y,$Z|Z".
00058       The Z is optional; if only "$X,$Y" is given, then "$X,$Y,0" is
00059       assumed.  */
00060    mmix_operands_regs_z_opt,
00061 
00062    /* The regular "$X,$Y,$Z|Z".  */
00063    mmix_operands_regs_z,
00064 
00065    /* "Address"; only JMP.  Zero operands allowed unless GNU syntax.  */
00066    mmix_operands_jmp,
00067 
00068    /* "$X|X,$Y,$Z|Z": PUSHGO; like "3", but X can be expressed as an
00069       integer.  */
00070    mmix_operands_pushgo,
00071 
00072    /* Two registers or a register and a byte, like FLOT, possibly with
00073       rounding: "$X,$Z|Z" or "$X,ROUND_MODE,$Z|Z".  */
00074    mmix_operands_roundregs_z,
00075 
00076    /* "X,YZ", POP.  Unless GNU syntax, zero or one operand is allowed.  */
00077    mmix_operands_pop,
00078 
00079    /* Two registers, possibly with rounding: "$X,$Z" or
00080       "$X,ROUND_MODE,$Z".  */
00081    mmix_operands_roundregs,
00082 
00083    /* "XYZ", like SYNC.  */
00084    mmix_operands_sync,
00085 
00086    /* "X,$Y,$Z|Z", like SYNCD.  */
00087    mmix_operands_x_regs_z,
00088 
00089    /* "$X,Y,$Z|Z", like NEG and NEGU.  The Y field is optional, default 0.  */
00090    mmix_operands_neg,
00091 
00092    /* "$X,Address, like GETA or branches.  */
00093    mmix_operands_regaddr,
00094 
00095    /* "$X|X,Address, like PUSHJ.  */
00096    mmix_operands_pushj,
00097 
00098    /* "$X,spec_reg"; GET.  */
00099    mmix_operands_get,
00100 
00101    /* "spec_reg,$Z|Z"; PUT.  */
00102    mmix_operands_put,
00103 
00104    /* Two registers, "$X,$Y".  */
00105    mmix_operands_set,
00106 
00107    /* "$X,0"; SAVE.  */
00108    mmix_operands_save,
00109 
00110    /* "0,$Z"; UNSAVE. */
00111    mmix_operands_unsave,
00112 
00113    /* "X,Y,Z"; like SWYM or TRAP.  Zero (or 1 if GNU syntax) to three
00114       operands, interpreted as 0; XYZ; X, YZ and X, Y, Z.  */
00115    mmix_operands_xyz_opt,
00116 
00117    /* Just "Z", like RESUME.  Unless GNU syntax, the operand can be omitted
00118       and will then be assumed zero.  */
00119    mmix_operands_resume,
00120 
00121    /* These are specials to handle that pseudo-directives are specified
00122       like ordinary insns when being mmixal-compatible.  They signify the
00123       specific pseudo-directive rather than the operands type.  */
00124 
00125    /* LOC.  */
00126    mmix_operands_loc,
00127 
00128    /* PREFIX.  */
00129    mmix_operands_prefix,
00130 
00131    /* BYTE.  */
00132    mmix_operands_byte,
00133 
00134    /* WYDE.  */
00135    mmix_operands_wyde,
00136 
00137    /* TETRA.  */
00138    mmix_operands_tetra,
00139 
00140    /* OCTA.  */
00141    mmix_operands_octa,
00142 
00143    /* LOCAL.  */
00144    mmix_operands_local,
00145 
00146    /* BSPEC.  */
00147    mmix_operands_bspec,
00148 
00149    /* ESPEC.  */
00150    mmix_operands_espec,
00151  };
00152 
00153 struct mmix_opcode
00154  {
00155    const char *name;
00156    unsigned long match;
00157    unsigned long lose;
00158    enum mmix_operands_type operands;
00159 
00160    /* This is used by the disassembly function.  */
00161    enum mmix_insn_type type;
00162  };
00163 
00164 /* Declare the actual tables.  */
00165 extern const struct mmix_opcode mmix_opcodes[];
00166 
00167 /* This one is terminated with an entry with a NULL name.  */
00168 extern const struct mmix_spec_reg mmix_spec_regs[];
00169 
00170 /* Some insn values we use when padding and synthesizing address loads.  */
00171 #define IMM_OFFSET_BIT 1
00172 #define COND_INV_BIT 0x8
00173 #define PRED_INV_BIT 0x10
00174 
00175 #define PUSHGO_INSN_BYTE 0xbe
00176 #define GO_INSN_BYTE 0x9e
00177 #define SETL_INSN_BYTE 0xe3
00178 #define INCML_INSN_BYTE 0xe6
00179 #define INCMH_INSN_BYTE 0xe5
00180 #define INCH_INSN_BYTE 0xe4
00181 #define SWYM_INSN_BYTE 0xfd
00182 #define JMP_INSN_BYTE 0xf0
00183 
00184 /* We can have 256 - 32 (local registers) - 1 ($255 is not allocatable)
00185    global registers.  */
00186 #define MAX_GREGS 223