Copyright 2002 Free Software Foundation, Inc.
This file is part of GDB and GAS.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
Initially created by Kuang Hwa Lin, 2002. */
#define ALUOP 0x00000000
#define SPECIALOP 0x00000000
#define NOPF 0x00000000
#define SLLF 0x00000004
#define SRLF 0x00000006
#define SRAF 0x00000007
#define SEQUF 0x00000010
#define SNEUF 0x00000011
#define SLTUF 0x00000012
#define SGTUF 0x00000013
#define SLEUF 0x00000014
#define SGEUF 0x00000015
#define ADDF 0x00000020
#define ADDUF 0x00000021
#define SUBF 0x00000022
#define SUBUF 0x00000023
#define ANDF 0x00000024
#define ORF 0x00000025
#define XORF 0x00000026
#define SEQF 0x00000028
#define SNEF 0x00000029
#define SLTF 0x0000002A
#define SGTF 0x0000002B
#define SLEF 0x0000002C
#define SGEF 0x0000002D
Hennessy's book but was implemented in the RTL. */
#define MVTSF 0x00000030
#define MVFSF 0x00000031
#define BSWAPF 0x00000032
#define LUTF 0x00000033
Hennessy's book but was not implemented in the RTL. */
#define MULTF 0x00000005
#define MULTUF 0x00000006
#define DIVF 0x00000007
#define DIVUF 0x00000008
JOP = (0x002 << 26), JALOP = (0x003 << 26), BEQOP = (0x004 << 26), BNEOP = (0x005 << 26)
ADDIOP = (0x008 << 26), ADDUIOP= (0x009 << 26), SUBIOP = (0x00A << 26), SUBUIOP= (0x00B << 26)
ANDIOP = (0x00C << 26), ORIOP = (0x00D << 26), XORIOP = (0x00E << 26), LHIOP = (0x00F << 26)
RFEOP = (0x010 << 26), TRAPOP = (0x011 << 26), JROP = (0x012 << 26), JALROP = (0x013 << 26)
BREAKOP= (0x014 << 26)
SEQIOP = (0x018 << 26), SNEIOP = (0x019 << 26), SLTIOP = (0x01A << 26), SGTIOP = (0x01B << 26)
SLEIOP = (0x01C << 26), SGEIOP = (0x01D << 26)
LBOP = (0x020 << 26), LHOP = (0x021 << 26), LWOP = (0x023 << 26), LBUOP = (0x024 << 26)
LHUOP = (0x025 << 26), SBOP = (0x028 << 26), SHOP = (0x029 << 26), SWOP = (0x02B << 26)
LSBUOP = (0x026 << 26), LSHU = (0x027 << 26), LSW = (0x02C << 26),
SEQUIOP= (0x030 << 26), SNEUIOP= (0x031 << 26), SLTUIOP= (0x032 << 26), SGTUIOP= (0x033 << 26)
SLEUIOP= (0x034 << 26), SGEUIOP= (0x035 << 26)
SLLIOP = (0x036 << 26), SRLIOP = (0x037 << 26), SRAIOP = (0x038 << 26). */
#define JOP 0x08000000
#define JALOP 0x0c000000
#define BEQOP 0x10000000
#define BNEOP 0x14000000
#define ADDIOP 0x20000000
#define ADDUIOP 0x24000000
#define SUBIOP 0x28000000
#define SUBUIOP 0x2c000000
#define ANDIOP 0x30000000
#define ORIOP 0x34000000
#define XORIOP 0x38000000
#define LHIOP 0x3c000000
#define RFEOP 0x40000000
#define TRAPOP 0x44000000
#define JROP 0x48000000
#define JALROP 0x4c000000
#define BREAKOP 0x50000000
#define SEQIOP 0x60000000
#define SNEIOP 0x64000000
#define SLTIOP 0x68000000
#define SGTIOP 0x6c000000
#define SLEIOP 0x70000000
#define SGEIOP 0x74000000
#define LBOP 0x80000000
#define LHOP 0x84000000
#define LWOP 0x8c000000
#define LBUOP 0x90000000
#define LHUOP 0x94000000
#define LDSTBU
#define LDSTHU
#define SBOP 0xa0000000
#define SHOP 0xa4000000
#define SWOP 0xac000000
#define LDST
#define SEQUIOP 0xc0000000
#define SNEUIOP 0xc4000000
#define SLTUIOP 0xc8000000
#define SGTUIOP 0xcc000000
#define SLEUIOP 0xd0000000
#define SGEUIOP 0xd4000000
#define SLLIOP 0xd8000000
#define SRLIOP 0xdc000000
#define SRAIOP 0xe0000000
#define LSBUOP 0x98000000
#define LSHUOP 0x9c000000
#define LSWOP 0xb0000000
"normal" opcode but was implemented in the RTL as special
functions. */
#if 0
#define MVTSOP 0x50000000
#define MVFSOP 0x54000000
#endif
struct dlx_opcode
{
char *name;
unsigned long opcode;
Valid characters are:
, Itself. The character appears in the assembly code.
a rs1 The register number is in bits 21-25 of the instruction.
b rs2/rd The register number is in bits 16-20 of the instruction.
c rd. The register number is in bits 11-15 of the instruction.
f FUNC bits 0-10 of the instruction.
i An immediate operand is in bits 0-16 of the instruction. 0 extended
I An immediate operand is in bits 0-16 of the instruction. sign extended
d An 16 bit PC relative displacement.
D An immediate operand is in bits 0-25 of the instruction.
N No opperands needed, for nops.
P it can be a register or a 16 bit operand. */
char *args;
};
static const struct dlx_opcode dlx_opcodes[] =
{
{ "nop", (ALUOP|NOPF), "N" },
{ "add", (ALUOP|ADDF), "c,a,b" },
{ "addu", (ALUOP|ADDUF), "c,a,b" },
{ "sub", (ALUOP|SUBF), "c,a,b" },
{ "subu", (ALUOP|SUBUF), "c,a,b" },
{ "mult", (ALUOP|MULTF), "c,a,b" },
{ "multu", (ALUOP|MULTUF), "c,a,b" },
{ "div", (ALUOP|DIVF), "c,a,b" },
{ "divu", (ALUOP|DIVUF), "c,a,b" },
{ "and", (ALUOP|ANDF), "c,a,b" },
{ "or", (ALUOP|ORF), "c,a,b" },
{ "xor", (ALUOP|XORF), "c,a,b" },
{ "sll", (ALUOP|SLLF), "c,a,b" },
{ "sra", (ALUOP|SRAF), "c,a,b" },
{ "srl", (ALUOP|SRLF), "c,a,b" },
{ "seq", (ALUOP|SEQF), "c,a,b" },
{ "sne", (ALUOP|SNEF), "c,a,b" },
{ "slt", (ALUOP|SLTF), "c,a,b" },
{ "sgt", (ALUOP|SGTF), "c,a,b" },
{ "sle", (ALUOP|SLEF), "c,a,b" },
{ "sge", (ALUOP|SGEF), "c,a,b" },
{ "sequ", (ALUOP|SEQUF), "c,a,b" },
{ "sneu", (ALUOP|SNEUF), "c,a,b" },
{ "sltu", (ALUOP|SLTUF), "c,a,b" },
{ "sgtu", (ALUOP|SGTUF), "c,a,b" },
{ "sleu", (ALUOP|SLEUF), "c,a,b" },
{ "sgeu", (ALUOP|SGEUF), "c,a,b" },
{ "mvts", (ALUOP|MVTSF), "c,a" },
{ "mvfs", (ALUOP|MVFSF), "c,a" },
{ "bswap", (ALUOP|BSWAPF), "c,a,b" },
{ "lut", (ALUOP|LUTF), "c,a,b" },
{ "addi", ADDIOP, "b,a,I" },
{ "addui", ADDUIOP, "b,a,i" },
{ "subi", SUBIOP, "b,a,I" },
{ "subui", SUBUIOP, "b,a,i" },
{ "andi", ANDIOP, "b,a,i" },
{ "ori", ORIOP, "b,a,i" },
{ "xori", XORIOP, "b,a,i" },
{ "slli", SLLIOP, "b,a,i" },
{ "srai", SRAIOP, "b,a,i" },
{ "srli", SRLIOP, "b,a,i" },
{ "seqi", SEQIOP, "b,a,i" },
{ "snei", SNEIOP, "b,a,i" },
{ "slti", SLTIOP, "b,a,i" },
{ "sgti", SGTIOP, "b,a,i" },
{ "slei", SLEIOP, "b,a,i" },
{ "sgei", SGEIOP, "b,a,i" },
{ "sequi", SEQUIOP, "b,a,i" },
{ "sneui", SNEUIOP, "b,a,i" },
{ "sltui", SLTUIOP, "b,a,i" },
{ "sgtui", SGTUIOP, "b,a,i" },
{ "sleui", SLEUIOP, "b,a,i" },
{ "sgeui", SGEUIOP, "b,a,i" },
{ "mov", ADDIOP, "b,P" },
{ "movu", ADDUIOP, "b,P" },
#if 0
{ "mvts", MVTSOP, "b,a" },
{ "mvfs", MVFSOP, "b,a" },
#endif
{ "lhi", LHIOP, "b,i" },
{ "lui", LHIOP, "b,i" },
{ "sethi", LHIOP, "b,i" },
{ "lb", LBOP, "b,a,I" },
{ "lbu", LBUOP, "b,a,I" },
{ "ldstbu", LSBUOP, "b,a,I" },
{ "sb", SBOP, "b,a,I" },
{ "lh", LHOP, "b,a,I" },
{ "lhu", LHUOP, "b,a,I" },
{ "ldsthu", LSHUOP, "b,a,I" },
{ "sh", SHOP, "b,a,I" },
{ "lw", LWOP, "b,a,I" },
{ "sw", SWOP, "b,a,I" },
{ "ldstw", LSWOP, "b,a,I" },
{ "beqz", BEQOP, "a,d" },
{ "bnez", BNEOP, "a,d" },
{ "beq", BEQOP, "a,d" },
{ "bne", BNEOP, "a,d" },
{ "j", JOP, "D" },
{ "jal", JALOP, "D" },
{ "break", BREAKOP, "D" },
{ "trap" , TRAPOP, "D" },
{ "rfe", RFEOP, "N" },
{ "call", JOP, "D" },
{ "jr", JROP, "a" },
{ "jalr", JALROP, "a" },
{ "retr", JROP, "a" },
{ "", 0x0, "" }
This lets code examine entry i + 1 without
checking if we've run off the end of the table. */
};
const unsigned int num_dlx_opcodes = (((sizeof dlx_opcodes) / (sizeof dlx_opcodes[0])) - 1);