1*3d8817e4Smiod /* Table of opcodes for the DLX microprocess. 2*3d8817e4Smiod Copyright 2002 Free Software Foundation, Inc. 3*3d8817e4Smiod 4*3d8817e4Smiod This file is part of GDB and GAS. 5*3d8817e4Smiod 6*3d8817e4Smiod This program is free software; you can redistribute it and/or modify 7*3d8817e4Smiod it under the terms of the GNU General Public License as published by 8*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or 9*3d8817e4Smiod (at your option) any later version. 10*3d8817e4Smiod 11*3d8817e4Smiod This program is distributed in the hope that it will be useful, 12*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of 13*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*3d8817e4Smiod GNU General Public License for more details. 15*3d8817e4Smiod 16*3d8817e4Smiod You should have received a copy of the GNU General Public License 17*3d8817e4Smiod along with this program; if not, write to the Free Software 18*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 19*3d8817e4Smiod 20*3d8817e4Smiod Initially created by Kuang Hwa Lin, 2002. */ 21*3d8817e4Smiod 22*3d8817e4Smiod /* Following are the function codes for the Special OP (ALU). */ 23*3d8817e4Smiod #define ALUOP 0x00000000 24*3d8817e4Smiod #define SPECIALOP 0x00000000 25*3d8817e4Smiod 26*3d8817e4Smiod #define NOPF 0x00000000 27*3d8817e4Smiod #define SLLF 0x00000004 28*3d8817e4Smiod #define SRLF 0x00000006 29*3d8817e4Smiod #define SRAF 0x00000007 30*3d8817e4Smiod 31*3d8817e4Smiod #define SEQUF 0x00000010 32*3d8817e4Smiod #define SNEUF 0x00000011 33*3d8817e4Smiod #define SLTUF 0x00000012 34*3d8817e4Smiod #define SGTUF 0x00000013 35*3d8817e4Smiod #define SLEUF 0x00000014 36*3d8817e4Smiod #define SGEUF 0x00000015 37*3d8817e4Smiod 38*3d8817e4Smiod #define ADDF 0x00000020 39*3d8817e4Smiod #define ADDUF 0x00000021 40*3d8817e4Smiod #define SUBF 0x00000022 41*3d8817e4Smiod #define SUBUF 0x00000023 42*3d8817e4Smiod #define ANDF 0x00000024 43*3d8817e4Smiod #define ORF 0x00000025 44*3d8817e4Smiod #define XORF 0x00000026 45*3d8817e4Smiod 46*3d8817e4Smiod #define SEQF 0x00000028 47*3d8817e4Smiod #define SNEF 0x00000029 48*3d8817e4Smiod #define SLTF 0x0000002A 49*3d8817e4Smiod #define SGTF 0x0000002B 50*3d8817e4Smiod #define SLEF 0x0000002C 51*3d8817e4Smiod #define SGEF 0x0000002D 52*3d8817e4Smiod /* Following special functions was not mentioned in the 53*3d8817e4Smiod Hennessy's book but was implemented in the RTL. */ 54*3d8817e4Smiod #define MVTSF 0x00000030 55*3d8817e4Smiod #define MVFSF 0x00000031 56*3d8817e4Smiod #define BSWAPF 0x00000032 57*3d8817e4Smiod #define LUTF 0x00000033 58*3d8817e4Smiod /* Following special functions was mentioned in the 59*3d8817e4Smiod Hennessy's book but was not implemented in the RTL. */ 60*3d8817e4Smiod #define MULTF 0x00000005 61*3d8817e4Smiod #define MULTUF 0x00000006 62*3d8817e4Smiod #define DIVF 0x00000007 63*3d8817e4Smiod #define DIVUF 0x00000008 64*3d8817e4Smiod 65*3d8817e4Smiod 66*3d8817e4Smiod /* Following are the rest of the OPcodes: 67*3d8817e4Smiod JOP = (0x002 << 26), JALOP = (0x003 << 26), BEQOP = (0x004 << 26), BNEOP = (0x005 << 26) 68*3d8817e4Smiod ADDIOP = (0x008 << 26), ADDUIOP= (0x009 << 26), SUBIOP = (0x00A << 26), SUBUIOP= (0x00B << 26) 69*3d8817e4Smiod ANDIOP = (0x00C << 26), ORIOP = (0x00D << 26), XORIOP = (0x00E << 26), LHIOP = (0x00F << 26) 70*3d8817e4Smiod RFEOP = (0x010 << 26), TRAPOP = (0x011 << 26), JROP = (0x012 << 26), JALROP = (0x013 << 26) 71*3d8817e4Smiod BREAKOP= (0x014 << 26) 72*3d8817e4Smiod SEQIOP = (0x018 << 26), SNEIOP = (0x019 << 26), SLTIOP = (0x01A << 26), SGTIOP = (0x01B << 26) 73*3d8817e4Smiod SLEIOP = (0x01C << 26), SGEIOP = (0x01D << 26) 74*3d8817e4Smiod LBOP = (0x020 << 26), LHOP = (0x021 << 26), LWOP = (0x023 << 26), LBUOP = (0x024 << 26) 75*3d8817e4Smiod LHUOP = (0x025 << 26), SBOP = (0x028 << 26), SHOP = (0x029 << 26), SWOP = (0x02B << 26) 76*3d8817e4Smiod LSBUOP = (0x026 << 26), LSHU = (0x027 << 26), LSW = (0x02C << 26), 77*3d8817e4Smiod SEQUIOP= (0x030 << 26), SNEUIOP= (0x031 << 26), SLTUIOP= (0x032 << 26), SGTUIOP= (0x033 << 26) 78*3d8817e4Smiod SLEUIOP= (0x034 << 26), SGEUIOP= (0x035 << 26) 79*3d8817e4Smiod SLLIOP = (0x036 << 26), SRLIOP = (0x037 << 26), SRAIOP = (0x038 << 26). */ 80*3d8817e4Smiod #define JOP 0x08000000 81*3d8817e4Smiod #define JALOP 0x0c000000 82*3d8817e4Smiod #define BEQOP 0x10000000 83*3d8817e4Smiod #define BNEOP 0x14000000 84*3d8817e4Smiod 85*3d8817e4Smiod #define ADDIOP 0x20000000 86*3d8817e4Smiod #define ADDUIOP 0x24000000 87*3d8817e4Smiod #define SUBIOP 0x28000000 88*3d8817e4Smiod #define SUBUIOP 0x2c000000 89*3d8817e4Smiod #define ANDIOP 0x30000000 90*3d8817e4Smiod #define ORIOP 0x34000000 91*3d8817e4Smiod #define XORIOP 0x38000000 92*3d8817e4Smiod #define LHIOP 0x3c000000 93*3d8817e4Smiod #define RFEOP 0x40000000 94*3d8817e4Smiod #define TRAPOP 0x44000000 95*3d8817e4Smiod #define JROP 0x48000000 96*3d8817e4Smiod #define JALROP 0x4c000000 97*3d8817e4Smiod #define BREAKOP 0x50000000 98*3d8817e4Smiod 99*3d8817e4Smiod #define SEQIOP 0x60000000 100*3d8817e4Smiod #define SNEIOP 0x64000000 101*3d8817e4Smiod #define SLTIOP 0x68000000 102*3d8817e4Smiod #define SGTIOP 0x6c000000 103*3d8817e4Smiod #define SLEIOP 0x70000000 104*3d8817e4Smiod #define SGEIOP 0x74000000 105*3d8817e4Smiod 106*3d8817e4Smiod #define LBOP 0x80000000 107*3d8817e4Smiod #define LHOP 0x84000000 108*3d8817e4Smiod #define LWOP 0x8c000000 109*3d8817e4Smiod #define LBUOP 0x90000000 110*3d8817e4Smiod #define LHUOP 0x94000000 111*3d8817e4Smiod #define LDSTBU 112*3d8817e4Smiod #define LDSTHU 113*3d8817e4Smiod #define SBOP 0xa0000000 114*3d8817e4Smiod #define SHOP 0xa4000000 115*3d8817e4Smiod #define SWOP 0xac000000 116*3d8817e4Smiod #define LDST 117*3d8817e4Smiod 118*3d8817e4Smiod #define SEQUIOP 0xc0000000 119*3d8817e4Smiod #define SNEUIOP 0xc4000000 120*3d8817e4Smiod #define SLTUIOP 0xc8000000 121*3d8817e4Smiod #define SGTUIOP 0xcc000000 122*3d8817e4Smiod #define SLEUIOP 0xd0000000 123*3d8817e4Smiod #define SGEUIOP 0xd4000000 124*3d8817e4Smiod 125*3d8817e4Smiod #define SLLIOP 0xd8000000 126*3d8817e4Smiod #define SRLIOP 0xdc000000 127*3d8817e4Smiod #define SRAIOP 0xe0000000 128*3d8817e4Smiod 129*3d8817e4Smiod /* Following 3 ops was added to provide the MP atonmic operation. */ 130*3d8817e4Smiod #define LSBUOP 0x98000000 131*3d8817e4Smiod #define LSHUOP 0x9c000000 132*3d8817e4Smiod #define LSWOP 0xb0000000 133*3d8817e4Smiod 134*3d8817e4Smiod /* Following opcode was defined in the Hennessy's book as 135*3d8817e4Smiod "normal" opcode but was implemented in the RTL as special 136*3d8817e4Smiod functions. */ 137*3d8817e4Smiod #if 0 138*3d8817e4Smiod #define MVTSOP 0x50000000 139*3d8817e4Smiod #define MVFSOP 0x54000000 140*3d8817e4Smiod #endif 141*3d8817e4Smiod 142*3d8817e4Smiod struct dlx_opcode 143*3d8817e4Smiod { 144*3d8817e4Smiod /* Name of the instruction. */ 145*3d8817e4Smiod char *name; 146*3d8817e4Smiod 147*3d8817e4Smiod /* Opcode word. */ 148*3d8817e4Smiod unsigned long opcode; 149*3d8817e4Smiod 150*3d8817e4Smiod /* A string of characters which describe the operands. 151*3d8817e4Smiod Valid characters are: 152*3d8817e4Smiod , Itself. The character appears in the assembly code. 153*3d8817e4Smiod a rs1 The register number is in bits 21-25 of the instruction. 154*3d8817e4Smiod b rs2/rd The register number is in bits 16-20 of the instruction. 155*3d8817e4Smiod c rd. The register number is in bits 11-15 of the instruction. 156*3d8817e4Smiod f FUNC bits 0-10 of the instruction. 157*3d8817e4Smiod i An immediate operand is in bits 0-16 of the instruction. 0 extended 158*3d8817e4Smiod I An immediate operand is in bits 0-16 of the instruction. sign extended 159*3d8817e4Smiod d An 16 bit PC relative displacement. 160*3d8817e4Smiod D An immediate operand is in bits 0-25 of the instruction. 161*3d8817e4Smiod N No opperands needed, for nops. 162*3d8817e4Smiod P it can be a register or a 16 bit operand. */ 163*3d8817e4Smiod char *args; 164*3d8817e4Smiod }; 165*3d8817e4Smiod 166*3d8817e4Smiod static const struct dlx_opcode dlx_opcodes[] = 167*3d8817e4Smiod { 168*3d8817e4Smiod /* Arithmetic and Logic R-TYPE instructions. */ 169*3d8817e4Smiod { "nop", (ALUOP|NOPF), "N" }, /* NOP */ 170*3d8817e4Smiod { "add", (ALUOP|ADDF), "c,a,b" }, /* Add */ 171*3d8817e4Smiod { "addu", (ALUOP|ADDUF), "c,a,b" }, /* Add Unsigned */ 172*3d8817e4Smiod { "sub", (ALUOP|SUBF), "c,a,b" }, /* SUB */ 173*3d8817e4Smiod { "subu", (ALUOP|SUBUF), "c,a,b" }, /* Sub Unsigned */ 174*3d8817e4Smiod { "mult", (ALUOP|MULTF), "c,a,b" }, /* MULTIPLY */ 175*3d8817e4Smiod { "multu", (ALUOP|MULTUF), "c,a,b" }, /* MULTIPLY Unsigned */ 176*3d8817e4Smiod { "div", (ALUOP|DIVF), "c,a,b" }, /* DIVIDE */ 177*3d8817e4Smiod { "divu", (ALUOP|DIVUF), "c,a,b" }, /* DIVIDE Unsigned */ 178*3d8817e4Smiod { "and", (ALUOP|ANDF), "c,a,b" }, /* AND */ 179*3d8817e4Smiod { "or", (ALUOP|ORF), "c,a,b" }, /* OR */ 180*3d8817e4Smiod { "xor", (ALUOP|XORF), "c,a,b" }, /* Exclusive OR */ 181*3d8817e4Smiod { "sll", (ALUOP|SLLF), "c,a,b" }, /* SHIFT LEFT LOGICAL */ 182*3d8817e4Smiod { "sra", (ALUOP|SRAF), "c,a,b" }, /* SHIFT RIGHT ARITHMETIC */ 183*3d8817e4Smiod { "srl", (ALUOP|SRLF), "c,a,b" }, /* SHIFT RIGHT LOGICAL */ 184*3d8817e4Smiod { "seq", (ALUOP|SEQF), "c,a,b" }, /* Set if equal */ 185*3d8817e4Smiod { "sne", (ALUOP|SNEF), "c,a,b" }, /* Set if not equal */ 186*3d8817e4Smiod { "slt", (ALUOP|SLTF), "c,a,b" }, /* Set if less */ 187*3d8817e4Smiod { "sgt", (ALUOP|SGTF), "c,a,b" }, /* Set if greater */ 188*3d8817e4Smiod { "sle", (ALUOP|SLEF), "c,a,b" }, /* Set if less or equal */ 189*3d8817e4Smiod { "sge", (ALUOP|SGEF), "c,a,b" }, /* Set if greater or equal */ 190*3d8817e4Smiod { "sequ", (ALUOP|SEQUF), "c,a,b" }, /* Set if equal unsigned */ 191*3d8817e4Smiod { "sneu", (ALUOP|SNEUF), "c,a,b" }, /* Set if not equal unsigned */ 192*3d8817e4Smiod { "sltu", (ALUOP|SLTUF), "c,a,b" }, /* Set if less unsigned */ 193*3d8817e4Smiod { "sgtu", (ALUOP|SGTUF), "c,a,b" }, /* Set if greater unsigned */ 194*3d8817e4Smiod { "sleu", (ALUOP|SLEUF), "c,a,b" }, /* Set if less or equal unsigned*/ 195*3d8817e4Smiod { "sgeu", (ALUOP|SGEUF), "c,a,b" }, /* Set if greater or equal */ 196*3d8817e4Smiod { "mvts", (ALUOP|MVTSF), "c,a" }, /* Move to special register */ 197*3d8817e4Smiod { "mvfs", (ALUOP|MVFSF), "c,a" }, /* Move from special register */ 198*3d8817e4Smiod { "bswap", (ALUOP|BSWAPF), "c,a,b" }, /* ??? Was not documented */ 199*3d8817e4Smiod { "lut", (ALUOP|LUTF), "c,a,b" }, /* ????? same as above */ 200*3d8817e4Smiod 201*3d8817e4Smiod /* Arithmetic and Logical Immediate I-TYPE instructions. */ 202*3d8817e4Smiod { "addi", ADDIOP, "b,a,I" }, /* Add Immediate */ 203*3d8817e4Smiod { "addui", ADDUIOP, "b,a,i" }, /* Add Usigned Immediate */ 204*3d8817e4Smiod { "subi", SUBIOP, "b,a,I" }, /* Sub Immediate */ 205*3d8817e4Smiod { "subui", SUBUIOP, "b,a,i" }, /* Sub Unsigned Immedated */ 206*3d8817e4Smiod { "andi", ANDIOP, "b,a,i" }, /* AND Immediate */ 207*3d8817e4Smiod { "ori", ORIOP, "b,a,i" }, /* OR Immediate */ 208*3d8817e4Smiod { "xori", XORIOP, "b,a,i" }, /* Exclusive OR Immediate */ 209*3d8817e4Smiod { "slli", SLLIOP, "b,a,i" }, /* SHIFT LEFT LOCICAL Immediate */ 210*3d8817e4Smiod { "srai", SRAIOP, "b,a,i" }, /* SHIFT RIGHT ARITH. Immediate */ 211*3d8817e4Smiod { "srli", SRLIOP, "b,a,i" }, /* SHIFT RIGHT LOGICAL Immediate*/ 212*3d8817e4Smiod { "seqi", SEQIOP, "b,a,i" }, /* Set if equal */ 213*3d8817e4Smiod { "snei", SNEIOP, "b,a,i" }, /* Set if not equal */ 214*3d8817e4Smiod { "slti", SLTIOP, "b,a,i" }, /* Set if less */ 215*3d8817e4Smiod { "sgti", SGTIOP, "b,a,i" }, /* Set if greater */ 216*3d8817e4Smiod { "slei", SLEIOP, "b,a,i" }, /* Set if less or equal */ 217*3d8817e4Smiod { "sgei", SGEIOP, "b,a,i" }, /* Set if greater or equal */ 218*3d8817e4Smiod { "sequi", SEQUIOP, "b,a,i" }, /* Set if equal */ 219*3d8817e4Smiod { "sneui", SNEUIOP, "b,a,i" }, /* Set if not equal */ 220*3d8817e4Smiod { "sltui", SLTUIOP, "b,a,i" }, /* Set if less */ 221*3d8817e4Smiod { "sgtui", SGTUIOP, "b,a,i" }, /* Set if greater */ 222*3d8817e4Smiod { "sleui", SLEUIOP, "b,a,i" }, /* Set if less or equal */ 223*3d8817e4Smiod { "sgeui", SGEUIOP, "b,a,i" }, /* Set if greater or equal */ 224*3d8817e4Smiod /* Macros for I type instructions. */ 225*3d8817e4Smiod { "mov", ADDIOP, "b,P" }, /* a move macro */ 226*3d8817e4Smiod { "movu", ADDUIOP, "b,P" }, /* a move macro, unsigned */ 227*3d8817e4Smiod 228*3d8817e4Smiod #if 0 229*3d8817e4Smiod /* Move special. */ 230*3d8817e4Smiod { "mvts", MVTSOP, "b,a" }, /* Move From Integer to Special */ 231*3d8817e4Smiod { "mvfs", MVFSOP, "b,a" }, /* Move From Special to Integer */ 232*3d8817e4Smiod #endif 233*3d8817e4Smiod 234*3d8817e4Smiod /* Load high Immediate I-TYPE instruction. */ 235*3d8817e4Smiod { "lhi", LHIOP, "b,i" }, /* Load High Immediate */ 236*3d8817e4Smiod { "lui", LHIOP, "b,i" }, /* Load High Immediate */ 237*3d8817e4Smiod { "sethi", LHIOP, "b,i" }, /* Load High Immediate */ 238*3d8817e4Smiod 239*3d8817e4Smiod /* LOAD/STORE BYTE 8 bits I-TYPE. */ 240*3d8817e4Smiod { "lb", LBOP, "b,a,I" }, /* Load Byte */ 241*3d8817e4Smiod { "lbu", LBUOP, "b,a,I" }, /* Load Byte Unsigned */ 242*3d8817e4Smiod { "ldstbu", LSBUOP, "b,a,I" }, /* Load store Byte Unsigned */ 243*3d8817e4Smiod { "sb", SBOP, "b,a,I" }, /* Store Byte */ 244*3d8817e4Smiod 245*3d8817e4Smiod /* LOAD/STORE HALFWORD 16 bits. */ 246*3d8817e4Smiod { "lh", LHOP, "b,a,I" }, /* Load Halfword */ 247*3d8817e4Smiod { "lhu", LHUOP, "b,a,I" }, /* Load Halfword Unsigned */ 248*3d8817e4Smiod { "ldsthu", LSHUOP, "b,a,I" }, /* Load Store Halfword Unsigned */ 249*3d8817e4Smiod { "sh", SHOP, "b,a,I" }, /* Store Halfword */ 250*3d8817e4Smiod 251*3d8817e4Smiod /* LOAD/STORE WORD 32 bits. */ 252*3d8817e4Smiod { "lw", LWOP, "b,a,I" }, /* Load Word */ 253*3d8817e4Smiod { "sw", SWOP, "b,a,I" }, /* Store Word */ 254*3d8817e4Smiod { "ldstw", LSWOP, "b,a,I" }, /* Load Store Word */ 255*3d8817e4Smiod 256*3d8817e4Smiod /* Branch PC-relative, 16 bits offset. */ 257*3d8817e4Smiod { "beqz", BEQOP, "a,d" }, /* Branch if a == 0 */ 258*3d8817e4Smiod { "bnez", BNEOP, "a,d" }, /* Branch if a != 0 */ 259*3d8817e4Smiod { "beq", BEQOP, "a,d" }, /* Branch if a == 0 */ 260*3d8817e4Smiod { "bne", BNEOP, "a,d" }, /* Branch if a != 0 */ 261*3d8817e4Smiod 262*3d8817e4Smiod /* Jumps Trap and RFE J-TYPE. */ 263*3d8817e4Smiod { "j", JOP, "D" }, /* Jump, PC-relative 26 bits */ 264*3d8817e4Smiod { "jal", JALOP, "D" }, /* JAL, PC-relative 26 bits */ 265*3d8817e4Smiod { "break", BREAKOP, "D" }, /* break to OS */ 266*3d8817e4Smiod { "trap" , TRAPOP, "D" }, /* TRAP to OS */ 267*3d8817e4Smiod { "rfe", RFEOP, "N" }, /* Return From Exception */ 268*3d8817e4Smiod /* Macros. */ 269*3d8817e4Smiod { "call", JOP, "D" }, /* Jump, PC-relative 26 bits */ 270*3d8817e4Smiod 271*3d8817e4Smiod /* Jumps Trap and RFE I-TYPE. */ 272*3d8817e4Smiod { "jr", JROP, "a" }, /* Jump Register, Abs (32 bits) */ 273*3d8817e4Smiod { "jalr", JALROP, "a" }, /* JALR, Abs (32 bits) */ 274*3d8817e4Smiod /* Macros. */ 275*3d8817e4Smiod { "retr", JROP, "a" }, /* Jump Register, Abs (32 bits) */ 276*3d8817e4Smiod 277*3d8817e4Smiod { "", 0x0, "" } /* Dummy entry, not included in NUM_OPCODES. 278*3d8817e4Smiod This lets code examine entry i + 1 without 279*3d8817e4Smiod checking if we've run off the end of the table. */ 280*3d8817e4Smiod }; 281*3d8817e4Smiod 282*3d8817e4Smiod const unsigned int num_dlx_opcodes = (((sizeof dlx_opcodes) / (sizeof dlx_opcodes[0])) - 1); 283