Home | History | Annotate | Line # | Download | only in opcodes
mmix-opc.c revision 1.11
      1   1.1  christos /* mmix-opc.c -- MMIX opcode table
      2  1.11  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 the GNU opcodes library.
      6   1.1  christos 
      7   1.1  christos    This library is free software; you can redistribute it and/or modify
      8   1.1  christos    it under the terms of the GNU General Public License as published by
      9   1.1  christos    the Free Software Foundation; either version 3, or (at your option)
     10   1.1  christos    any later version.
     11   1.1  christos 
     12   1.1  christos    It is distributed in the hope that it will be useful, but WITHOUT
     13   1.1  christos    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     14   1.1  christos    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
     15   1.1  christos    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 COPYING.  If not, write to the
     19   1.1  christos    Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
     20   1.1  christos    MA 02110-1301, USA.  */
     21   1.1  christos 
     22   1.1  christos #include <stdio.h>
     23   1.1  christos #include "opcode/mmix.h"
     24   1.1  christos #include "symcat.h"
     25   1.1  christos 
     26   1.1  christos /* Register-name-table for special registers.  */
     27   1.1  christos const struct mmix_spec_reg mmix_spec_regs[] =
     28   1.1  christos  {
     29   1.1  christos    /* Keep rJ at top; it's the most frequently used one.  */
     30   1.1  christos    {"rJ", 4},
     31   1.1  christos    {"rA", 21},
     32   1.1  christos    {"rB", 0},
     33   1.1  christos    {"rC", 8},
     34   1.1  christos    {"rD", 1},
     35   1.1  christos    {"rE", 2},
     36   1.1  christos    {"rF", 22},
     37   1.1  christos    {"rG", 19},
     38   1.1  christos    {"rH", 3},
     39   1.1  christos    {"rI", 12},
     40   1.1  christos    {"rK", 15},
     41   1.1  christos    {"rL", 20},
     42   1.1  christos    {"rM", 5},
     43   1.1  christos    {"rN", 9},
     44   1.1  christos    {"rO", 10},
     45   1.1  christos    {"rP", 23},
     46   1.1  christos    {"rQ", 16},
     47   1.1  christos    {"rR", 6},
     48   1.1  christos    {"rS", 11},
     49   1.1  christos    {"rT", 13},
     50   1.1  christos    {"rU", 17},
     51   1.1  christos    {"rV", 18},
     52   1.1  christos    {"rW", 24},
     53   1.1  christos    {"rX", 25},
     54   1.1  christos    {"rY", 26},
     55   1.1  christos    {"rZ", 27},
     56   1.1  christos    {"rBB", 7},
     57   1.1  christos    {"rTT", 14},
     58   1.1  christos    {"rWW", 28},
     59   1.1  christos    {"rXX", 29},
     60   1.1  christos    {"rYY", 30},
     61   1.1  christos    {"rZZ", 31},
     62   1.1  christos    {NULL, 0}
     63   1.1  christos  };
     64   1.1  christos 
     65   1.1  christos /* Opcode-table.  In order to cut down on redundant contents, we use helper
     66   1.1  christos    macros.  */
     67   1.1  christos 
     68   1.1  christos /* All bits in the opcode-byte are significant.  Add "| ..." expressions
     69   1.1  christos    to add zero-bits.  */
     70   1.1  christos #undef O
     71   1.1  christos #define O(m) ((unsigned long) (m) << 24UL), ((~(unsigned long) (m) & 255) << 24)
     72   1.1  christos 
     73   1.1  christos /* Bits 7..1 of the opcode are significant.  */
     74   1.1  christos #undef Z
     75   1.1  christos #define Z(m) ((unsigned long) (m) << 24), ((~(unsigned long) (m) & 254) << 24)
     76   1.1  christos 
     77   1.1  christos /* For easier overview of the table.  */
     78   1.1  christos #define N mmix_type_normal
     79   1.1  christos #define B mmix_type_branch
     80   1.1  christos #define C mmix_type_condbranch
     81   1.1  christos #define MB mmix_type_memaccess_byte
     82   1.1  christos #define MW mmix_type_memaccess_wyde
     83   1.1  christos #define MT mmix_type_memaccess_tetra
     84   1.1  christos #define MO mmix_type_memaccess_octa
     85   1.1  christos #define M mmix_type_memaccess_block
     86   1.1  christos #define J mmix_type_jsr
     87   1.1  christos #define P mmix_type_pseudo
     88   1.1  christos 
     89   1.1  christos #define OP(y) XCONCAT2 (mmix_operands_,y)
     90   1.1  christos 
     91   1.1  christos /* Groups of instructions specified here must, if all are matching the
     92   1.1  christos    same instruction, be consecutive, in order more-specific to
     93   1.1  christos    less-specific match.  */
     94   1.1  christos 
     95   1.1  christos const struct mmix_opcode mmix_opcodes[] =
     96   1.1  christos  {
     97   1.1  christos    {"trap",	O (0),		OP (xyz_opt),		J},
     98   1.1  christos    {"fcmp",	O (1),		OP (regs),		N},
     99   1.1  christos    {"flot",	Z (8),		OP (roundregs_z),	N},
    100   1.1  christos 
    101   1.1  christos    {"fun",	O (2),		OP (regs),		N},
    102   1.1  christos    {"feql",	O (3),		OP (regs),		N},
    103   1.1  christos    {"flotu",	Z (10),		OP (roundregs_z),	N},
    104   1.1  christos 
    105   1.1  christos    {"fadd",	O (4),		OP (regs),		N},
    106   1.1  christos    {"fix",	O (5),		OP (roundregs),		N},
    107   1.1  christos    {"sflot",	Z (12),		OP (roundregs_z),	N},
    108   1.1  christos 
    109   1.1  christos    {"fsub",	O (6),		OP (regs),		N},
    110   1.1  christos    {"fixu",	O (7),		OP (roundregs),		N},
    111   1.1  christos    {"sflotu",	Z (14),		OP (roundregs_z),	N},
    112   1.1  christos 
    113   1.1  christos    {"fmul",	O (16),		OP (regs),		N},
    114   1.1  christos    {"fcmpe",	O (17),		OP (regs),		N},
    115   1.1  christos    {"mul",	Z (24),		OP (regs_z),		N},
    116   1.1  christos 
    117   1.1  christos    {"fune",	O (18),		OP (regs),		N},
    118   1.1  christos    {"feqle",	O (19),		OP (regs),		N},
    119   1.1  christos    {"mulu",	Z (26),		OP (regs_z),		N},
    120   1.1  christos 
    121   1.1  christos    {"fdiv",	O (20),		OP (regs),		N},
    122   1.1  christos    {"fsqrt",	O (21),		OP (roundregs),		N},
    123   1.1  christos    {"div",	Z (28),		OP (regs_z),		N},
    124   1.1  christos 
    125   1.1  christos    {"frem",	O (22),		OP (regs),		N},
    126   1.1  christos    {"fint",	O (23),		OP (roundregs),		N},
    127   1.1  christos    {"divu",	Z (30),		OP (regs_z),		N},
    128   1.1  christos 
    129   1.1  christos    {"add",	Z (0x20),	OP (regs_z),		N},
    130   1.1  christos    {"2addu",	Z (0x28),	OP (regs_z),		N},
    131   1.1  christos 
    132   1.1  christos    {"addu",	Z (0x22),	OP (regs_z),		N},
    133   1.1  christos    /* Synonym for ADDU.  Put after ADDU, since we don't prefer it for
    134   1.1  christos       disassembly.  It's supposed to be used for addresses, so we make it
    135   1.1  christos       a memory block reference for purposes of assembly.  */
    136   1.1  christos    {"lda",	Z (0x22),	OP (regs_z_opt),	M},
    137   1.1  christos    {"4addu",	Z (0x2a),	OP (regs_z),		N},
    138   1.1  christos 
    139   1.1  christos    {"sub",	Z (0x24),	OP (regs_z),		N},
    140   1.1  christos    {"8addu",	Z (0x2c),	OP (regs_z),		N},
    141   1.1  christos 
    142   1.1  christos    {"subu",	Z (0x26),	OP (regs_z),		N},
    143   1.1  christos    {"16addu",	Z (0x2e),	OP (regs_z),		N},
    144   1.1  christos 
    145   1.1  christos    {"cmp",	Z (0x30),	OP (regs_z),		N},
    146   1.1  christos    {"sl",	Z (0x38),	OP (regs_z),		N},
    147   1.1  christos 
    148   1.1  christos    {"cmpu",	Z (0x32),	OP (regs_z),		N},
    149   1.1  christos    {"slu",	Z (0x3a),	OP (regs_z),		N},
    150   1.1  christos 
    151   1.1  christos    {"neg",	Z (0x34),	OP (neg),		N},
    152   1.1  christos    {"sr",	Z (0x3c),	OP (regs_z),		N},
    153   1.1  christos 
    154   1.1  christos    {"negu",	Z (0x36),	OP (neg),		N},
    155   1.1  christos    {"sru",	Z (0x3e),	OP (regs_z),		N},
    156   1.1  christos 
    157   1.1  christos    {"bn",	Z (0x40),	OP (regaddr),		C},
    158   1.1  christos    {"bnn",	Z (0x48),	OP (regaddr),		C},
    159   1.1  christos 
    160   1.1  christos    {"bz",	Z (0x42),	OP (regaddr),		C},
    161   1.1  christos    {"bnz",	Z (0x4a),	OP (regaddr),		C},
    162   1.1  christos 
    163   1.1  christos    {"bp",	Z (0x44),	OP (regaddr),		C},
    164   1.1  christos    {"bnp",	Z (0x4c),	OP (regaddr),		C},
    165   1.1  christos 
    166   1.1  christos    {"bod",	Z (0x46),	OP (regaddr),		C},
    167   1.1  christos    {"bev",	Z (0x4e),	OP (regaddr),		C},
    168   1.1  christos 
    169   1.1  christos    {"pbn",	Z (0x50),	OP (regaddr),		C},
    170   1.1  christos    {"pbnn",	Z (0x58),	OP (regaddr),		C},
    171   1.1  christos 
    172   1.1  christos    {"pbz",	Z (0x52),	OP (regaddr),		C},
    173   1.1  christos    {"pbnz",	Z (0x5a),	OP (regaddr),		C},
    174   1.1  christos 
    175   1.1  christos    {"pbp",	Z (0x54),	OP (regaddr),		C},
    176   1.1  christos    {"pbnp",	Z (0x5c),	OP (regaddr),		C},
    177   1.1  christos 
    178   1.1  christos    {"pbod",	Z (0x56),	OP (regaddr),		C},
    179   1.1  christos    {"pbev",	Z (0x5e),	OP (regaddr),		C},
    180   1.1  christos 
    181   1.1  christos    {"csn",	Z (0x60),	OP (regs_z),		N},
    182   1.1  christos    {"csnn",	Z (0x68),	OP (regs_z),		N},
    183   1.1  christos 
    184   1.1  christos    {"csz",	Z (0x62),	OP (regs_z),		N},
    185   1.1  christos    {"csnz",	Z (0x6a),	OP (regs_z),		N},
    186   1.1  christos 
    187   1.1  christos    {"csp",	Z (0x64),	OP (regs_z),		N},
    188   1.1  christos    {"csnp",	Z (0x6c),	OP (regs_z),		N},
    189   1.1  christos 
    190   1.1  christos    {"csod",	Z (0x66),	OP (regs_z),		N},
    191   1.1  christos    {"csev",	Z (0x6e),	OP (regs_z),		N},
    192   1.1  christos 
    193   1.1  christos    {"zsn",	Z (0x70),	OP (regs_z),		N},
    194   1.1  christos    {"zsnn",	Z (0x78),	OP (regs_z),		N},
    195   1.1  christos 
    196   1.1  christos    {"zsz",	Z (0x72),	OP (regs_z),		N},
    197   1.1  christos    {"zsnz",	Z (0x7a),	OP (regs_z),		N},
    198   1.1  christos 
    199   1.1  christos    {"zsp",	Z (0x74),	OP (regs_z),		N},
    200   1.1  christos    {"zsnp",	Z (0x7c),	OP (regs_z),		N},
    201   1.1  christos 
    202   1.1  christos    {"zsod",	Z (0x76),	OP (regs_z),		N},
    203   1.1  christos    {"zsev",	Z (0x7e),	OP (regs_z),		N},
    204   1.1  christos 
    205   1.1  christos    {"ldb",	Z (0x80),	OP (regs_z_opt),	MB},
    206   1.1  christos    {"ldt",	Z (0x88),	OP (regs_z_opt),	MT},
    207   1.1  christos 
    208   1.1  christos    {"ldbu",	Z (0x82),	OP (regs_z_opt),	MB},
    209   1.1  christos    {"ldtu",	Z (0x8a),	OP (regs_z_opt),	MT},
    210   1.1  christos 
    211   1.1  christos    {"ldw",	Z (0x84),	OP (regs_z_opt),	MW},
    212   1.1  christos    {"ldo",	Z (0x8c),	OP (regs_z_opt),	MO},
    213   1.1  christos 
    214   1.1  christos    {"ldwu",	Z (0x86),	OP (regs_z_opt),	MW},
    215   1.1  christos    {"ldou",	Z (0x8e),	OP (regs_z_opt),	MO},
    216   1.1  christos 
    217   1.1  christos    {"ldsf",	Z (0x90),	OP (regs_z_opt),	MT},
    218   1.1  christos 
    219   1.1  christos    /* This doesn't seem to access memory, just the TLB.  */
    220   1.1  christos    {"ldvts",	Z (0x98),	OP (regs_z_opt),	M},
    221   1.1  christos 
    222   1.1  christos    {"ldht",	Z (0x92),	OP (regs_z_opt),	MT},
    223   1.1  christos 
    224   1.1  christos    /* Neither does this per-se.  */
    225   1.1  christos    {"preld",	Z (0x9a),	OP (x_regs_z),		N},
    226   1.1  christos 
    227   1.1  christos    {"cswap",	Z (0x94),	OP (regs_z_opt),	MO},
    228   1.1  christos    {"prego",	Z (0x9c),	OP (x_regs_z),		N},
    229   1.1  christos 
    230   1.1  christos    {"ldunc",	Z (0x96),	OP (regs_z_opt),	MO},
    231   1.1  christos    {"go",	Z (GO_INSN_BYTE),
    232   1.1  christos 				OP (regs_z_opt),	B},
    233   1.1  christos 
    234   1.1  christos    {"stb",	Z (0xa0),	OP (regs_z_opt),	MB},
    235   1.1  christos    {"stt",	Z (0xa8),	OP (regs_z_opt),	MT},
    236   1.1  christos 
    237   1.1  christos    {"stbu",	Z (0xa2),	OP (regs_z_opt),	MB},
    238   1.1  christos    {"sttu",	Z (0xaa),	OP (regs_z_opt),	MT},
    239   1.1  christos 
    240   1.1  christos    {"stw",	Z (0xa4),	OP (regs_z_opt),	MW},
    241   1.1  christos    {"sto",	Z (0xac),	OP (regs_z_opt),	MO},
    242   1.1  christos 
    243   1.1  christos    {"stwu",	Z (0xa6),	OP (regs_z_opt),	MW},
    244   1.1  christos    {"stou",	Z (0xae),	OP (regs_z_opt),	MO},
    245   1.1  christos 
    246   1.1  christos    {"stsf",	Z (0xb0),	OP (regs_z_opt),	MT},
    247   1.1  christos    {"syncd",	Z (0xb8),	OP (x_regs_z),		M},
    248   1.1  christos 
    249   1.1  christos    {"stht",	Z (0xb2),	OP (regs_z_opt),	MT},
    250   1.1  christos    {"prest",	Z (0xba),	OP (x_regs_z),		M},
    251   1.1  christos 
    252   1.1  christos    {"stco",	Z (0xb4),	OP (x_regs_z),		MO},
    253   1.1  christos    {"syncid",	Z (0xbc),	OP (x_regs_z),		M},
    254   1.1  christos 
    255   1.1  christos    {"stunc",	Z (0xb6),	OP (regs_z_opt),	MO},
    256   1.1  christos    {"pushgo",	Z (PUSHGO_INSN_BYTE),
    257   1.1  christos 				OP (pushgo),		J},
    258   1.1  christos 
    259   1.1  christos    /* Synonym for OR with a zero Z.  */
    260   1.1  christos    {"set",	O (0xc1)
    261   1.1  christos 		  | 0xff,	OP (set),		N},
    262   1.1  christos 
    263   1.1  christos    {"or",	Z (0xc0),	OP (regs_z),		N},
    264   1.1  christos    {"and",	Z (0xc8),	OP (regs_z),		N},
    265   1.1  christos 
    266   1.1  christos    {"orn",	Z (0xc2),	OP (regs_z),		N},
    267   1.1  christos    {"andn",	Z (0xca),	OP (regs_z),		N},
    268   1.1  christos 
    269   1.1  christos    {"nor",	Z (0xc4),	OP (regs_z),		N},
    270   1.1  christos    {"nand",	Z (0xcc),	OP (regs_z),		N},
    271   1.1  christos 
    272   1.1  christos    {"xor",	Z (0xc6),	OP (regs_z),		N},
    273   1.1  christos    {"nxor",	Z (0xce),	OP (regs_z),		N},
    274   1.1  christos 
    275   1.1  christos    {"bdif",	Z (0xd0),	OP (regs_z),		N},
    276   1.1  christos    {"mux",	Z (0xd8),	OP (regs_z),		N},
    277   1.1  christos 
    278   1.1  christos    {"wdif",	Z (0xd2),	OP (regs_z),		N},
    279   1.1  christos    {"sadd",	Z (0xda),	OP (regs_z),		N},
    280   1.1  christos 
    281   1.1  christos    {"tdif",	Z (0xd4),	OP (regs_z),		N},
    282   1.1  christos    {"mor",	Z (0xdc),	OP (regs_z),		N},
    283   1.1  christos 
    284   1.1  christos    {"odif",	Z (0xd6),	OP (regs_z),		N},
    285   1.1  christos    {"mxor",	Z (0xde),	OP (regs_z),		N},
    286   1.1  christos 
    287   1.1  christos    {"seth",	O (0xe0),	OP (reg_yz),		N},
    288   1.1  christos    {"setmh",	O (0xe1),	OP (reg_yz),		N},
    289   1.1  christos    {"orh",	O (0xe8),	OP (reg_yz),		N},
    290   1.1  christos    {"ormh",	O (0xe9),	OP (reg_yz),		N},
    291   1.1  christos 
    292   1.1  christos    {"setml",	O (0xe2),	OP (reg_yz),		N},
    293   1.1  christos    {"setl",	O (SETL_INSN_BYTE),
    294   1.1  christos 				OP (reg_yz),		N},
    295   1.1  christos    {"orml",	O (0xea),	OP (reg_yz),		N},
    296   1.1  christos    {"orl",	O (0xeb),	OP (reg_yz),		N},
    297   1.1  christos 
    298   1.1  christos    {"inch",	O (INCH_INSN_BYTE),
    299   1.1  christos 				OP (reg_yz),		N},
    300   1.1  christos    {"incmh",	O (INCMH_INSN_BYTE),
    301   1.1  christos 				OP (reg_yz),		N},
    302   1.1  christos    {"andnh",	O (0xec),	OP (reg_yz),		N},
    303   1.1  christos    {"andnmh",	O (0xed),	OP (reg_yz),		N},
    304   1.1  christos 
    305   1.1  christos    {"incml",	O (INCML_INSN_BYTE),
    306   1.1  christos 				OP (reg_yz),		N},
    307   1.1  christos    {"incl",	O (0xe7),	OP (reg_yz),		N},
    308   1.1  christos    {"andnml",	O (0xee),	OP (reg_yz),		N},
    309   1.1  christos    {"andnl",	O (0xef),	OP (reg_yz),		N},
    310   1.1  christos 
    311   1.1  christos    {"jmp",	Z (0xf0),	OP (jmp),		B},
    312   1.1  christos    {"pop",	O (0xf8),	OP (pop),		B},
    313   1.1  christos    {"resume",	O (0xf9)
    314   1.1  christos 		  | 0xffff00,	OP (resume),		B},
    315   1.1  christos 
    316   1.1  christos    {"pushj",	Z (0xf2),	OP (pushj),		J},
    317   1.1  christos    {"save",	O (0xfa)
    318   1.1  christos 		  | 0xffff,	OP (save),		M},
    319   1.1  christos    {"unsave",	O (0xfb)
    320   1.1  christos 		  | 0xffff00,	OP (unsave),		M},
    321   1.1  christos 
    322   1.1  christos    {"geta",	Z (0xf4),	OP (regaddr),		N},
    323   1.1  christos    {"sync",	O (0xfc),	OP (sync),		N},
    324   1.1  christos    {"swym",	O (SWYM_INSN_BYTE),
    325   1.1  christos 				OP (xyz_opt),		N},
    326   1.1  christos 
    327   1.1  christos    {"put", Z (0xf6) | 0xff00,	OP (put),		N},
    328   1.1  christos    {"get", O (0xfe) | 0xffe0,	OP (get),		N},
    329   1.1  christos    {"trip",	O (0xff),	OP (xyz_opt),		J},
    330   1.1  christos 
    331   1.1  christos    /* We have mmixal pseudos in the ordinary instruction table so we can
    332   1.1  christos       avoid the "set" vs. ".set" ambiguity that would be the effect if we
    333   1.1  christos       had pseudos handled "normally" and defined NO_PSEUDO_DOT.
    334   1.1  christos 
    335   1.1  christos       Note that IS and GREG are handled fully by md_start_line_hook, so
    336   1.1  christos       they're not here.  */
    337   1.1  christos    {"loc",	~0, ~0,		OP (loc),		P},
    338   1.1  christos    {"prefix",	~0, ~0,		OP (prefix),		P},
    339   1.1  christos    {"byte",	~0, ~0,		OP (byte),		P},
    340   1.1  christos    {"wyde",	~0, ~0,		OP (wyde),		P},
    341   1.1  christos    {"tetra",	~0, ~0,		OP (tetra),		P},
    342   1.1  christos    {"octa",	~0, ~0,		OP (octa),		P},
    343   1.1  christos    {"local",	~0, ~0,		OP (local),		P},
    344   1.1  christos    {"bspec",	~0, ~0,		OP (bspec),		P},
    345   1.1  christos    {"espec",	~0, ~0,		OP (espec),		P},
    346   1.1  christos 
    347   1.1  christos    {NULL, ~0, ~0, OP (none), N}
    348   1.1  christos  };
    349