198b9484cSchristos /* Table of opcodes for the DLX microprocess. 2*02f41505Schristos Copyright (C) 2002-2024 Free Software Foundation, Inc. 398b9484cSchristos 498b9484cSchristos This file is part of GDB and GAS. 598b9484cSchristos 698b9484cSchristos This program is free software; you can redistribute it and/or modify 798b9484cSchristos it under the terms of the GNU General Public License as published by 898b9484cSchristos the Free Software Foundation; either version 3 of the License, or 998b9484cSchristos (at your option) any later version. 1098b9484cSchristos 1198b9484cSchristos This program is distributed in the hope that it will be useful, 1298b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1398b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1498b9484cSchristos GNU General Public License for more details. 1598b9484cSchristos 1698b9484cSchristos You should have received a copy of the GNU General Public License 1798b9484cSchristos along with this program; if not, write to the Free Software 1898b9484cSchristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 1998b9484cSchristos MA 02110-1301, USA. 2098b9484cSchristos 2198b9484cSchristos Initially created by Kuang Hwa Lin, 2002. */ 2298b9484cSchristos 2398b9484cSchristos /* Following are the function codes for the Special OP (ALU). */ 2498b9484cSchristos #define ALUOP 0x00000000 2598b9484cSchristos #define SPECIALOP 0x00000000 2698b9484cSchristos 2798b9484cSchristos #define NOPF 0x00000000 2898b9484cSchristos #define SLLF 0x00000004 2998b9484cSchristos #define SRLF 0x00000006 3098b9484cSchristos #define SRAF 0x00000007 3198b9484cSchristos 3298b9484cSchristos #define SEQUF 0x00000010 3398b9484cSchristos #define SNEUF 0x00000011 3498b9484cSchristos #define SLTUF 0x00000012 3598b9484cSchristos #define SGTUF 0x00000013 3698b9484cSchristos #define SLEUF 0x00000014 3798b9484cSchristos #define SGEUF 0x00000015 3898b9484cSchristos 3998b9484cSchristos #define ADDF 0x00000020 4098b9484cSchristos #define ADDUF 0x00000021 4198b9484cSchristos #define SUBF 0x00000022 4298b9484cSchristos #define SUBUF 0x00000023 4398b9484cSchristos #define ANDF 0x00000024 4498b9484cSchristos #define ORF 0x00000025 4598b9484cSchristos #define XORF 0x00000026 4698b9484cSchristos 4798b9484cSchristos #define SEQF 0x00000028 4898b9484cSchristos #define SNEF 0x00000029 4998b9484cSchristos #define SLTF 0x0000002A 5098b9484cSchristos #define SGTF 0x0000002B 5198b9484cSchristos #define SLEF 0x0000002C 5298b9484cSchristos #define SGEF 0x0000002D 5398b9484cSchristos /* Following special functions was not mentioned in the 5498b9484cSchristos Hennessy's book but was implemented in the RTL. */ 5598b9484cSchristos #define MVTSF 0x00000030 5698b9484cSchristos #define MVFSF 0x00000031 5798b9484cSchristos #define BSWAPF 0x00000032 5898b9484cSchristos #define LUTF 0x00000033 5998b9484cSchristos /* Following special functions was mentioned in the 6098b9484cSchristos Hennessy's book but was not implemented in the RTL. */ 6198b9484cSchristos #define MULTF 0x00000005 6298b9484cSchristos #define MULTUF 0x00000006 6398b9484cSchristos #define DIVF 0x00000007 6498b9484cSchristos #define DIVUF 0x00000008 6598b9484cSchristos 6698b9484cSchristos 6798b9484cSchristos /* Following are the rest of the OPcodes: 6898b9484cSchristos JOP = (0x002 << 26), JALOP = (0x003 << 26), BEQOP = (0x004 << 26), BNEOP = (0x005 << 26) 6998b9484cSchristos ADDIOP = (0x008 << 26), ADDUIOP= (0x009 << 26), SUBIOP = (0x00A << 26), SUBUIOP= (0x00B << 26) 7098b9484cSchristos ANDIOP = (0x00C << 26), ORIOP = (0x00D << 26), XORIOP = (0x00E << 26), LHIOP = (0x00F << 26) 7198b9484cSchristos RFEOP = (0x010 << 26), TRAPOP = (0x011 << 26), JROP = (0x012 << 26), JALROP = (0x013 << 26) 7298b9484cSchristos BREAKOP= (0x014 << 26) 7398b9484cSchristos SEQIOP = (0x018 << 26), SNEIOP = (0x019 << 26), SLTIOP = (0x01A << 26), SGTIOP = (0x01B << 26) 7498b9484cSchristos SLEIOP = (0x01C << 26), SGEIOP = (0x01D << 26) 7598b9484cSchristos LBOP = (0x020 << 26), LHOP = (0x021 << 26), LWOP = (0x023 << 26), LBUOP = (0x024 << 26) 7698b9484cSchristos LHUOP = (0x025 << 26), SBOP = (0x028 << 26), SHOP = (0x029 << 26), SWOP = (0x02B << 26) 7798b9484cSchristos LSBUOP = (0x026 << 26), LSHU = (0x027 << 26), LSW = (0x02C << 26), 7898b9484cSchristos SEQUIOP= (0x030 << 26), SNEUIOP= (0x031 << 26), SLTUIOP= (0x032 << 26), SGTUIOP= (0x033 << 26) 7998b9484cSchristos SLEUIOP= (0x034 << 26), SGEUIOP= (0x035 << 26) 8098b9484cSchristos SLLIOP = (0x036 << 26), SRLIOP = (0x037 << 26), SRAIOP = (0x038 << 26). */ 8198b9484cSchristos #define JOP 0x08000000 8298b9484cSchristos #define JALOP 0x0c000000 8398b9484cSchristos #define BEQOP 0x10000000 8498b9484cSchristos #define BNEOP 0x14000000 8598b9484cSchristos 8698b9484cSchristos #define ADDIOP 0x20000000 8798b9484cSchristos #define ADDUIOP 0x24000000 8898b9484cSchristos #define SUBIOP 0x28000000 8998b9484cSchristos #define SUBUIOP 0x2c000000 9098b9484cSchristos #define ANDIOP 0x30000000 9198b9484cSchristos #define ORIOP 0x34000000 9298b9484cSchristos #define XORIOP 0x38000000 9398b9484cSchristos #define LHIOP 0x3c000000 9498b9484cSchristos #define RFEOP 0x40000000 9598b9484cSchristos #define TRAPOP 0x44000000 9698b9484cSchristos #define JROP 0x48000000 9798b9484cSchristos #define JALROP 0x4c000000 9898b9484cSchristos #define BREAKOP 0x50000000 9998b9484cSchristos 10098b9484cSchristos #define SEQIOP 0x60000000 10198b9484cSchristos #define SNEIOP 0x64000000 10298b9484cSchristos #define SLTIOP 0x68000000 10398b9484cSchristos #define SGTIOP 0x6c000000 10498b9484cSchristos #define SLEIOP 0x70000000 10598b9484cSchristos #define SGEIOP 0x74000000 10698b9484cSchristos 10798b9484cSchristos #define LBOP 0x80000000 10898b9484cSchristos #define LHOP 0x84000000 10998b9484cSchristos #define LWOP 0x8c000000 11098b9484cSchristos #define LBUOP 0x90000000 11198b9484cSchristos #define LHUOP 0x94000000 11298b9484cSchristos #define LDSTBU 11398b9484cSchristos #define LDSTHU 11498b9484cSchristos #define SBOP 0xa0000000 11598b9484cSchristos #define SHOP 0xa4000000 11698b9484cSchristos #define SWOP 0xac000000 11798b9484cSchristos #define LDST 11898b9484cSchristos 11998b9484cSchristos #define SEQUIOP 0xc0000000 12098b9484cSchristos #define SNEUIOP 0xc4000000 12198b9484cSchristos #define SLTUIOP 0xc8000000 12298b9484cSchristos #define SGTUIOP 0xcc000000 12398b9484cSchristos #define SLEUIOP 0xd0000000 12498b9484cSchristos #define SGEUIOP 0xd4000000 12598b9484cSchristos 12698b9484cSchristos #define SLLIOP 0xd8000000 12798b9484cSchristos #define SRLIOP 0xdc000000 12898b9484cSchristos #define SRAIOP 0xe0000000 12998b9484cSchristos 13098b9484cSchristos /* Following 3 ops was added to provide the MP atonmic operation. */ 13198b9484cSchristos #define LSBUOP 0x98000000 13298b9484cSchristos #define LSHUOP 0x9c000000 13398b9484cSchristos #define LSWOP 0xb0000000 13498b9484cSchristos 13598b9484cSchristos /* Following opcode was defined in the Hennessy's book as 13698b9484cSchristos "normal" opcode but was implemented in the RTL as special 13798b9484cSchristos functions. */ 13898b9484cSchristos #if 0 13998b9484cSchristos #define MVTSOP 0x50000000 14098b9484cSchristos #define MVFSOP 0x54000000 14198b9484cSchristos #endif 14298b9484cSchristos 14398b9484cSchristos struct dlx_opcode 14498b9484cSchristos { 14598b9484cSchristos /* Name of the instruction. */ 146ba340e45Schristos const char *name; 14798b9484cSchristos 14898b9484cSchristos /* Opcode word. */ 14998b9484cSchristos unsigned long opcode; 15098b9484cSchristos 15198b9484cSchristos /* A string of characters which describe the operands. 15298b9484cSchristos Valid characters are: 15398b9484cSchristos , Itself. The character appears in the assembly code. 15498b9484cSchristos a rs1 The register number is in bits 21-25 of the instruction. 15598b9484cSchristos b rs2/rd The register number is in bits 16-20 of the instruction. 15698b9484cSchristos c rd. The register number is in bits 11-15 of the instruction. 15798b9484cSchristos f FUNC bits 0-10 of the instruction. 15898b9484cSchristos i An immediate operand is in bits 0-16 of the instruction. 0 extended 15998b9484cSchristos I An immediate operand is in bits 0-16 of the instruction. sign extended 16098b9484cSchristos d An 16 bit PC relative displacement. 16198b9484cSchristos D An immediate operand is in bits 0-25 of the instruction. 16298b9484cSchristos N No opperands needed, for nops. 16398b9484cSchristos P it can be a register or a 16 bit operand. */ 164ba340e45Schristos const char *args; 16598b9484cSchristos }; 16698b9484cSchristos 16798b9484cSchristos static const struct dlx_opcode dlx_opcodes[] = 16898b9484cSchristos { 16998b9484cSchristos /* Arithmetic and Logic R-TYPE instructions. */ 17098b9484cSchristos { "nop", (ALUOP|NOPF), "N" }, /* NOP */ 17198b9484cSchristos { "add", (ALUOP|ADDF), "c,a,b" }, /* Add */ 17298b9484cSchristos { "addu", (ALUOP|ADDUF), "c,a,b" }, /* Add Unsigned */ 17398b9484cSchristos { "sub", (ALUOP|SUBF), "c,a,b" }, /* SUB */ 17498b9484cSchristos { "subu", (ALUOP|SUBUF), "c,a,b" }, /* Sub Unsigned */ 17598b9484cSchristos { "mult", (ALUOP|MULTF), "c,a,b" }, /* MULTIPLY */ 17698b9484cSchristos { "multu", (ALUOP|MULTUF), "c,a,b" }, /* MULTIPLY Unsigned */ 17798b9484cSchristos { "div", (ALUOP|DIVF), "c,a,b" }, /* DIVIDE */ 17898b9484cSchristos { "divu", (ALUOP|DIVUF), "c,a,b" }, /* DIVIDE Unsigned */ 17998b9484cSchristos { "and", (ALUOP|ANDF), "c,a,b" }, /* AND */ 18098b9484cSchristos { "or", (ALUOP|ORF), "c,a,b" }, /* OR */ 18198b9484cSchristos { "xor", (ALUOP|XORF), "c,a,b" }, /* Exclusive OR */ 18298b9484cSchristos { "sll", (ALUOP|SLLF), "c,a,b" }, /* SHIFT LEFT LOGICAL */ 18398b9484cSchristos { "sra", (ALUOP|SRAF), "c,a,b" }, /* SHIFT RIGHT ARITHMETIC */ 18498b9484cSchristos { "srl", (ALUOP|SRLF), "c,a,b" }, /* SHIFT RIGHT LOGICAL */ 18598b9484cSchristos { "seq", (ALUOP|SEQF), "c,a,b" }, /* Set if equal */ 18698b9484cSchristos { "sne", (ALUOP|SNEF), "c,a,b" }, /* Set if not equal */ 18798b9484cSchristos { "slt", (ALUOP|SLTF), "c,a,b" }, /* Set if less */ 18898b9484cSchristos { "sgt", (ALUOP|SGTF), "c,a,b" }, /* Set if greater */ 18998b9484cSchristos { "sle", (ALUOP|SLEF), "c,a,b" }, /* Set if less or equal */ 19098b9484cSchristos { "sge", (ALUOP|SGEF), "c,a,b" }, /* Set if greater or equal */ 19198b9484cSchristos { "sequ", (ALUOP|SEQUF), "c,a,b" }, /* Set if equal unsigned */ 19298b9484cSchristos { "sneu", (ALUOP|SNEUF), "c,a,b" }, /* Set if not equal unsigned */ 19398b9484cSchristos { "sltu", (ALUOP|SLTUF), "c,a,b" }, /* Set if less unsigned */ 19498b9484cSchristos { "sgtu", (ALUOP|SGTUF), "c,a,b" }, /* Set if greater unsigned */ 19598b9484cSchristos { "sleu", (ALUOP|SLEUF), "c,a,b" }, /* Set if less or equal unsigned*/ 19698b9484cSchristos { "sgeu", (ALUOP|SGEUF), "c,a,b" }, /* Set if greater or equal */ 19798b9484cSchristos { "mvts", (ALUOP|MVTSF), "c,a" }, /* Move to special register */ 19898b9484cSchristos { "mvfs", (ALUOP|MVFSF), "c,a" }, /* Move from special register */ 19998b9484cSchristos { "bswap", (ALUOP|BSWAPF), "c,a,b" }, /* ??? Was not documented */ 20098b9484cSchristos { "lut", (ALUOP|LUTF), "c,a,b" }, /* ????? same as above */ 20198b9484cSchristos 20298b9484cSchristos /* Arithmetic and Logical Immediate I-TYPE instructions. */ 20398b9484cSchristos { "addi", ADDIOP, "b,a,I" }, /* Add Immediate */ 20498b9484cSchristos { "addui", ADDUIOP, "b,a,i" }, /* Add Usigned Immediate */ 20598b9484cSchristos { "subi", SUBIOP, "b,a,I" }, /* Sub Immediate */ 20698b9484cSchristos { "subui", SUBUIOP, "b,a,i" }, /* Sub Unsigned Immedated */ 20798b9484cSchristos { "andi", ANDIOP, "b,a,i" }, /* AND Immediate */ 20898b9484cSchristos { "ori", ORIOP, "b,a,i" }, /* OR Immediate */ 20998b9484cSchristos { "xori", XORIOP, "b,a,i" }, /* Exclusive OR Immediate */ 21098b9484cSchristos { "slli", SLLIOP, "b,a,i" }, /* SHIFT LEFT LOCICAL Immediate */ 21198b9484cSchristos { "srai", SRAIOP, "b,a,i" }, /* SHIFT RIGHT ARITH. Immediate */ 21298b9484cSchristos { "srli", SRLIOP, "b,a,i" }, /* SHIFT RIGHT LOGICAL Immediate*/ 21398b9484cSchristos { "seqi", SEQIOP, "b,a,i" }, /* Set if equal */ 21498b9484cSchristos { "snei", SNEIOP, "b,a,i" }, /* Set if not equal */ 21598b9484cSchristos { "slti", SLTIOP, "b,a,i" }, /* Set if less */ 21698b9484cSchristos { "sgti", SGTIOP, "b,a,i" }, /* Set if greater */ 21798b9484cSchristos { "slei", SLEIOP, "b,a,i" }, /* Set if less or equal */ 21898b9484cSchristos { "sgei", SGEIOP, "b,a,i" }, /* Set if greater or equal */ 21998b9484cSchristos { "sequi", SEQUIOP, "b,a,i" }, /* Set if equal */ 22098b9484cSchristos { "sneui", SNEUIOP, "b,a,i" }, /* Set if not equal */ 22198b9484cSchristos { "sltui", SLTUIOP, "b,a,i" }, /* Set if less */ 22298b9484cSchristos { "sgtui", SGTUIOP, "b,a,i" }, /* Set if greater */ 22398b9484cSchristos { "sleui", SLEUIOP, "b,a,i" }, /* Set if less or equal */ 22498b9484cSchristos { "sgeui", SGEUIOP, "b,a,i" }, /* Set if greater or equal */ 22598b9484cSchristos /* Macros for I type instructions. */ 22698b9484cSchristos { "mov", ADDIOP, "b,P" }, /* a move macro */ 22798b9484cSchristos { "movu", ADDUIOP, "b,P" }, /* a move macro, unsigned */ 22898b9484cSchristos 22998b9484cSchristos #if 0 23098b9484cSchristos /* Move special. */ 23198b9484cSchristos { "mvts", MVTSOP, "b,a" }, /* Move From Integer to Special */ 23298b9484cSchristos { "mvfs", MVFSOP, "b,a" }, /* Move From Special to Integer */ 23398b9484cSchristos #endif 23498b9484cSchristos 23598b9484cSchristos /* Load high Immediate I-TYPE instruction. */ 23698b9484cSchristos { "lhi", LHIOP, "b,i" }, /* Load High Immediate */ 23798b9484cSchristos { "lui", LHIOP, "b,i" }, /* Load High Immediate */ 23898b9484cSchristos { "sethi", LHIOP, "b,i" }, /* Load High Immediate */ 23998b9484cSchristos 24098b9484cSchristos /* LOAD/STORE BYTE 8 bits I-TYPE. */ 24198b9484cSchristos { "lb", LBOP, "b,a,I" }, /* Load Byte */ 24298b9484cSchristos { "lbu", LBUOP, "b,a,I" }, /* Load Byte Unsigned */ 24398b9484cSchristos { "ldstbu", LSBUOP, "b,a,I" }, /* Load store Byte Unsigned */ 24498b9484cSchristos { "sb", SBOP, "b,a,I" }, /* Store Byte */ 24598b9484cSchristos 24698b9484cSchristos /* LOAD/STORE HALFWORD 16 bits. */ 24798b9484cSchristos { "lh", LHOP, "b,a,I" }, /* Load Halfword */ 24898b9484cSchristos { "lhu", LHUOP, "b,a,I" }, /* Load Halfword Unsigned */ 24998b9484cSchristos { "ldsthu", LSHUOP, "b,a,I" }, /* Load Store Halfword Unsigned */ 25098b9484cSchristos { "sh", SHOP, "b,a,I" }, /* Store Halfword */ 25198b9484cSchristos 25298b9484cSchristos /* LOAD/STORE WORD 32 bits. */ 25398b9484cSchristos { "lw", LWOP, "b,a,I" }, /* Load Word */ 25498b9484cSchristos { "sw", SWOP, "b,a,I" }, /* Store Word */ 25598b9484cSchristos { "ldstw", LSWOP, "b,a,I" }, /* Load Store Word */ 25698b9484cSchristos 25798b9484cSchristos /* Branch PC-relative, 16 bits offset. */ 25898b9484cSchristos { "beqz", BEQOP, "a,d" }, /* Branch if a == 0 */ 25998b9484cSchristos { "bnez", BNEOP, "a,d" }, /* Branch if a != 0 */ 26098b9484cSchristos { "beq", BEQOP, "a,d" }, /* Branch if a == 0 */ 26198b9484cSchristos { "bne", BNEOP, "a,d" }, /* Branch if a != 0 */ 26298b9484cSchristos 26398b9484cSchristos /* Jumps Trap and RFE J-TYPE. */ 26498b9484cSchristos { "j", JOP, "D" }, /* Jump, PC-relative 26 bits */ 26598b9484cSchristos { "jal", JALOP, "D" }, /* JAL, PC-relative 26 bits */ 26698b9484cSchristos { "break", BREAKOP, "D" }, /* break to OS */ 26798b9484cSchristos { "trap" , TRAPOP, "D" }, /* TRAP to OS */ 26898b9484cSchristos { "rfe", RFEOP, "N" }, /* Return From Exception */ 26998b9484cSchristos /* Macros. */ 27098b9484cSchristos { "call", JOP, "D" }, /* Jump, PC-relative 26 bits */ 27198b9484cSchristos 27298b9484cSchristos /* Jumps Trap and RFE I-TYPE. */ 27398b9484cSchristos { "jr", JROP, "a" }, /* Jump Register, Abs (32 bits) */ 27498b9484cSchristos { "jalr", JALROP, "a" }, /* JALR, Abs (32 bits) */ 27598b9484cSchristos /* Macros. */ 27698b9484cSchristos { "retr", JROP, "a" }, /* Jump Register, Abs (32 bits) */ 27798b9484cSchristos 27898b9484cSchristos { "", 0x0, "" } /* Dummy entry, not included in NUM_OPCODES. 27998b9484cSchristos This lets code examine entry i + 1 without 28098b9484cSchristos checking if we've run off the end of the table. */ 28198b9484cSchristos }; 28298b9484cSchristos 28398b9484cSchristos const unsigned int num_dlx_opcodes = (((sizeof dlx_opcodes) / (sizeof dlx_opcodes[0])) - 1); 284