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