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