xref: /netbsd-src/external/gpl3/gdb/dist/include/opcode/pyr.h (revision 02f41505626a9ceb584d30d0789203495760ac88)
198b9484cSchristos /* pyramid.opcode.h -- gdb initial attempt.
298b9484cSchristos 
3*02f41505Schristos    Copyright (C) 2001-2024 Free Software Foundation, Inc.
498b9484cSchristos 
598b9484cSchristos    This program is free software; you can redistribute it and/or modify
698b9484cSchristos    it under the terms of the GNU General Public License as published by
798b9484cSchristos    the Free Software Foundation; either version 3, or (at your option)
898b9484cSchristos    any later version.
998b9484cSchristos 
1098b9484cSchristos    This program is distributed in the hope that it will be useful,
1198b9484cSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1298b9484cSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1398b9484cSchristos    GNU General Public License for more details.
1498b9484cSchristos 
1598b9484cSchristos    You should have received a copy of the GNU General Public License
1698b9484cSchristos    along with this program; if not, write to the Free Software
1798b9484cSchristos    Foundation, Inc., 51 Franklin Street - Fifth Floor,
1898b9484cSchristos    Boston, MA 02110-1301, USA.  */
1998b9484cSchristos 
2098b9484cSchristos /* pyramid opcode table: wot to do with this
2198b9484cSchristos    particular opcode */
2298b9484cSchristos 
2398b9484cSchristos struct pyr_datum
2498b9484cSchristos {
2598b9484cSchristos   char              nargs;
2698b9484cSchristos   char *            args;	/* how to compile said opcode */
2798b9484cSchristos   unsigned long     mask;	/* Bit vector: which operand modes are valid
2898b9484cSchristos 				   for this opcode */
2998b9484cSchristos   unsigned char     code;	/* op-code (always 6(?) bits */
3098b9484cSchristos };
3198b9484cSchristos 
3298b9484cSchristos typedef struct pyr_insn_format
3398b9484cSchristos {
3498b9484cSchristos     unsigned int mode :4;
3598b9484cSchristos     unsigned int operator :8;
3698b9484cSchristos     unsigned int index_scale :2;
3798b9484cSchristos     unsigned int index_reg :6;
3898b9484cSchristos     unsigned int operand_1 :6;
3998b9484cSchristos     unsigned int operand_2:6;
4098b9484cSchristos } pyr_insn_format;
4198b9484cSchristos 
4298b9484cSchristos 
4398b9484cSchristos /* We store four bytes of opcode for all opcodes.
4498b9484cSchristos    Pyramid is sufficiently RISCy that:
4598b9484cSchristos       - insns are always an integral number of words;
4698b9484cSchristos       - the length of any insn can be told from the first word of
4798b9484cSchristos         the insn. (ie, if there are zero, one, or two words of
4898b9484cSchristos 	immediate operand/offset).
4998b9484cSchristos 
5098b9484cSchristos 
5198b9484cSchristos    The args component is a string containing two characters for each
5298b9484cSchristos    operand of the instruction.  The first specifies the kind of operand;
5398b9484cSchristos    the second, the place it is stored. */
5498b9484cSchristos 
5598b9484cSchristos /* Kinds of operands:
5698b9484cSchristos    mask	 assembler syntax	description
5798b9484cSchristos    0x0001:  movw Rn,Rn		register to register
5898b9484cSchristos    0x0002:  movw K,Rn		quick immediate to register
5998b9484cSchristos    0x0004:  movw I,Rn		long immediate to register
6098b9484cSchristos    0x0008:  movw (Rn),Rn	register indirect to register
6198b9484cSchristos    	    movw (Rn)[x],Rn	register indirect to register
6298b9484cSchristos    0x0010:  movw I(Rn),Rn	offset register indirect to register
6398b9484cSchristos    	    movw I(Rn)[x],Rn	offset register indirect, indexed, to register
6498b9484cSchristos 
6598b9484cSchristos    0x0020:  movw Rn,(Rn)	register to register indirect
6698b9484cSchristos    0x0040:  movw K,(Rn)		quick immediate to register indirect
6798b9484cSchristos    0x0080:  movw I,(Rn)		long immediate to register indirect
6898b9484cSchristos    0x0100:  movw (Rn),(Rn)	register indirect to-register indirect
6998b9484cSchristos    0x0100:  movw (Rn),(Rn)	register indirect to-register indirect
7098b9484cSchristos    0x0200:  movw I(Rn),(Rn)	register indirect+offset to register indirect
7198b9484cSchristos    0x0200:  movw I(Rn),(Rn)	register indirect+offset to register indirect
7298b9484cSchristos 
7398b9484cSchristos    0x0400:  movw Rn,I(Rn)	register to register indirect+offset
7498b9484cSchristos    0x0800:  movw K,I(Rn)	quick immediate to register indirect+offset
7598b9484cSchristos    0x1000:  movw I,I(Rn)	long immediate to register indirect+offset
7698b9484cSchristos    0x1000:  movw (Rn),I(Rn)	register indirect to-register indirect+offset
7798b9484cSchristos    0x1000:  movw I(Rn),I(Rn)	register indirect+offset to register indirect
7898b9484cSchristos    					+offset
7998b9484cSchristos    0x0000:  (irregular)		???
8098b9484cSchristos 
8198b9484cSchristos 
8298b9484cSchristos    Each insn has a four-bit field encoding the type(s) of its operands.
8398b9484cSchristos */
8498b9484cSchristos 
8598b9484cSchristos /* Some common combinations
8698b9484cSchristos    */
8798b9484cSchristos 
8898b9484cSchristos /* the first 5,(0x1|0x2|0x4|0x8|0x10) ie (1|2|4|8|16), ie ( 32 -1)*/
8998b9484cSchristos #define GEN_TO_REG (31)
9098b9484cSchristos 
9198b9484cSchristos #define	UNKNOWN ((unsigned long)-1)
9298b9484cSchristos #define ANY (GEN_TO_REG | (GEN_TO_REG << 5) | (GEN_TO_REG << 15))
9398b9484cSchristos 
9498b9484cSchristos #define CONVERT (1|8|0x10|0x20|0x200)
9598b9484cSchristos 
9698b9484cSchristos #define K_TO_REG (2)
9798b9484cSchristos #define I_TO_REG (4)
9898b9484cSchristos #define NOTK_TO_REG (GEN_TO_REG & ~K_TO_REG)
9998b9484cSchristos #define NOTI_TO_REG (GEN_TO_REG & ~I_TO_REG)
10098b9484cSchristos 
10198b9484cSchristos /* The assembler requires that this array be sorted as follows:
10298b9484cSchristos    all instances of the same mnemonic must be consecutive.
10398b9484cSchristos    All instances of the same mnemonic with the same number of operands
10498b9484cSchristos    must be consecutive.
10598b9484cSchristos  */
10698b9484cSchristos 
10798b9484cSchristos struct pyr_opcode		/* pyr opcode text */
10898b9484cSchristos {
10998b9484cSchristos   char *            name;	/* opcode name: lowercase string  [key]  */
11098b9484cSchristos   struct pyr_datum  datum;	/* rest of opcode table          [datum] */
11198b9484cSchristos };
11298b9484cSchristos 
11398b9484cSchristos #define pyr_how args
11498b9484cSchristos #define pyr_nargs nargs
11598b9484cSchristos #define pyr_mask mask
11698b9484cSchristos #define pyr_name name
11798b9484cSchristos 
11898b9484cSchristos struct pyr_opcode pyr_opcodes[] =
11998b9484cSchristos {
12098b9484cSchristos   {"movb",	{ 2, "", UNKNOWN,		0x11}, },
12198b9484cSchristos   {"movh",	{ 2, "", UNKNOWN,		0x12} },
12298b9484cSchristos   {"movw",	{ 2, "", ANY,			0x10} },
12398b9484cSchristos   {"movl",	{ 2, "", ANY,			0x13} },
12498b9484cSchristos   {"mnegw",	{ 2, "", (0x1|0x8|0x10),	0x14} },
12598b9484cSchristos   {"mnegf",	{ 2, "", 0x1,			0x15} },
12698b9484cSchristos   {"mnegd",	{ 2, "", 0x1,			0x16} },
12798b9484cSchristos   {"mcomw",	{ 2, "", (0x1|0x8|0x10),	0x17} },
12898b9484cSchristos   {"mabsw",	{ 2, "", (0x1|0x8|0x10),	0x18} },
12998b9484cSchristos   {"mabsf",	{ 2, "", 0x1,			0x19} },
13098b9484cSchristos   {"mabsd",	{ 2, "", 0x1,			0x1a} },
13198b9484cSchristos   {"mtstw",	{ 2, "", (0x1|0x8|0x10),	0x1c} },
13298b9484cSchristos   {"mtstf",	{ 2, "", 0x1,			0x1d} },
13398b9484cSchristos   {"mtstd",	{ 2, "", 0x1,			0x1e} },
13498b9484cSchristos   {"mova",	{ 2, "", 0x8|0x10,		0x1f} },
13598b9484cSchristos   {"movzbw",	{ 2, "", (0x1|0x8|0x10),	0x20} },
13698b9484cSchristos   {"movzhw",	{ 2, "", (0x1|0x8|0x10),	0x21} },
13798b9484cSchristos 				/* 2 insns out of order here */
13898b9484cSchristos   {"movbl",	{ 2, "", 1,			0x4f} },
13998b9484cSchristos   {"filbl",	{ 2, "", 1,			0x4e} },
14098b9484cSchristos 
14198b9484cSchristos   {"cvtbw",	{ 2, "", CONVERT,		0x22} },
14298b9484cSchristos   {"cvthw",	{ 2, "", CONVERT,		0x23} },
14398b9484cSchristos   {"cvtwb",	{ 2, "", CONVERT,		0x24} },
14498b9484cSchristos   {"cvtwh",	{ 2, "", CONVERT,		0x25} },
14598b9484cSchristos   {"cvtwf",	{ 2, "", CONVERT,		0x26} },
14698b9484cSchristos   {"cvtwd",	{ 2, "", CONVERT,		0x27} },
14798b9484cSchristos   {"cvtfw",	{ 2, "", CONVERT,		0x28} },
14898b9484cSchristos   {"cvtfd",	{ 2, "", CONVERT,		0x29} },
14998b9484cSchristos   {"cvtdw",	{ 2, "", CONVERT,		0x2a} },
15098b9484cSchristos   {"cvtdf",	{ 2, "", CONVERT,		0x2b} },
15198b9484cSchristos 
15298b9484cSchristos   {"addw",	{ 2, "", GEN_TO_REG,		0x40} },
15398b9484cSchristos   {"addwc",	{ 2, "", GEN_TO_REG,		0x41} },
15498b9484cSchristos   {"subw",	{ 2, "", GEN_TO_REG,		0x42} },
15598b9484cSchristos   {"subwb",	{ 2, "", GEN_TO_REG,		0x43} },
15698b9484cSchristos   {"rsubw",	{ 2, "", GEN_TO_REG,		0x44} },
15798b9484cSchristos   {"mulw",	{ 2, "", GEN_TO_REG,		0x45} },
15898b9484cSchristos   {"emul",	{ 2, "", GEN_TO_REG,		0x47} },
15998b9484cSchristos   {"umulw",	{ 2, "", GEN_TO_REG,		0x46} },
16098b9484cSchristos   {"divw",	{ 2, "", GEN_TO_REG,		0x48} },
16198b9484cSchristos   {"ediv",	{ 2, "", GEN_TO_REG,		0x4a} },
16298b9484cSchristos   {"rdivw",	{ 2, "", GEN_TO_REG,		0x4b} },
16398b9484cSchristos   {"udivw",	{ 2, "", GEN_TO_REG,		0x49} },
16498b9484cSchristos   {"modw",	{ 2, "", GEN_TO_REG,		0x4c} },
16598b9484cSchristos   {"umodw",	{ 2, "", GEN_TO_REG,		0x4d} },
16698b9484cSchristos 
16798b9484cSchristos 
16898b9484cSchristos   {"addf",	{ 2, "", 1,			0x50} },
16998b9484cSchristos   {"addd",	{ 2, "", 1,			0x51} },
17098b9484cSchristos   {"subf",	{ 2, "", 1,			0x52} },
17198b9484cSchristos   {"subd",	{ 2, "", 1,			0x53} },
17298b9484cSchristos   {"mulf",	{ 2, "", 1,			0x56} },
17398b9484cSchristos   {"muld",	{ 2, "", 1,			0x57} },
17498b9484cSchristos   {"divf",	{ 2, "", 1,			0x58} },
17598b9484cSchristos   {"divd",	{ 2, "", 1,			0x59} },
17698b9484cSchristos 
17798b9484cSchristos 
17898b9484cSchristos   {"cmpb",	{ 2, "", UNKNOWN,		0x61} },
17998b9484cSchristos   {"cmph",	{ 2, "", UNKNOWN,		0x62} },
18098b9484cSchristos   {"cmpw",	{ 2, "", UNKNOWN,		0x60} },
18198b9484cSchristos   {"ucmpb",	{ 2, "", UNKNOWN,		0x66} },
18298b9484cSchristos   /* WHY no "ucmph"??? */
18398b9484cSchristos   {"ucmpw",	{ 2, "", UNKNOWN,		0x65} },
18498b9484cSchristos   {"xchw",	{ 2, "", UNKNOWN,		0x0f} },
18598b9484cSchristos 
18698b9484cSchristos 
18798b9484cSchristos   {"andw",	{ 2, "", GEN_TO_REG,		0x30} },
18898b9484cSchristos   {"orw",	{ 2, "", GEN_TO_REG,		0x31} },
18998b9484cSchristos   {"xorw",	{ 2, "", GEN_TO_REG,		0x32} },
19098b9484cSchristos   {"bicw",	{ 2, "", GEN_TO_REG,		0x33} },
19198b9484cSchristos   {"lshlw",	{ 2, "", GEN_TO_REG,		0x38} },
19298b9484cSchristos   {"ashlw",	{ 2, "", GEN_TO_REG,		0x3a} },
19398b9484cSchristos   {"ashll",	{ 2, "", GEN_TO_REG,		0x3c} },
19498b9484cSchristos   {"ashrw",	{ 2, "", GEN_TO_REG,		0x3b} },
19598b9484cSchristos   {"ashrl",	{ 2, "", GEN_TO_REG,		0x3d} },
19698b9484cSchristos   {"rotlw",	{ 2, "", GEN_TO_REG,		0x3e} },
19798b9484cSchristos   {"rotrw",	{ 2, "", GEN_TO_REG,		0x3f} },
19898b9484cSchristos 
19998b9484cSchristos   /* push and pop insns are "going away next release". */
20098b9484cSchristos   {"pushw",	{ 2, "", GEN_TO_REG,		0x0c} },
20198b9484cSchristos   {"popw",	{ 2, "", (0x1|0x8|0x10),	0x0d} },
20298b9484cSchristos   {"pusha",	{ 2, "", (0x8|0x10),		0x0e} },
20398b9484cSchristos 
20498b9484cSchristos   {"bitsw",	{ 2, "", UNKNOWN,		0x35} },
20598b9484cSchristos   {"bitcw",	{ 2, "", UNKNOWN,		0x36} },
20698b9484cSchristos   /* some kind of ibra/dbra insns??*/
20798b9484cSchristos   {"icmpw",	{ 2, "", UNKNOWN,		0x67} },
20898b9484cSchristos   {"dcmpw",	{ 2, "", (1|4|0x20|0x80|0x400|0x1000),	0x69} },/*FIXME*/
20998b9484cSchristos   {"acmpw",	{ 2, "", 1,			0x6b} },
21098b9484cSchristos 
21198b9484cSchristos   /* Call is written as a 1-op insn, but is always (dis)assembled as a 2-op
21298b9484cSchristos      insn with a 2nd op of tr14.   The assembler will have to grok this.  */
21398b9484cSchristos   {"call",	{ 2, "", GEN_TO_REG,		0x04} },
21498b9484cSchristos   {"call",	{ 1, "", GEN_TO_REG,		0x04} },
21598b9484cSchristos 
21698b9484cSchristos   {"callk",	{ 1, "", UNKNOWN,		0x06} },/* system call?*/
21798b9484cSchristos   /* Ret is usually written as a 0-op insn, but gets disassembled as a
21898b9484cSchristos      1-op insn. The operand is always tr15. */
21998b9484cSchristos   {"ret",	{ 0, "", UNKNOWN,		0x09} },
22098b9484cSchristos   {"ret",	{ 1, "", UNKNOWN,		0x09} },
22198b9484cSchristos   {"adsf",	{ 2, "", (1|2|4),		0x08} },
22298b9484cSchristos   {"retd",	{ 2, "", UNKNOWN,		0x0a} },
22398b9484cSchristos   {"btc",	{ 2, "", UNKNOWN,		0x01} },
22498b9484cSchristos   {"bfc",	{ 2, "", UNKNOWN,		0x02} },
22598b9484cSchristos   /* Careful: halt is 0x00000000. Jump must have some other (mode?)bit set?? */
22698b9484cSchristos   {"jump",	{ 1, "", UNKNOWN,		0x00} },
22798b9484cSchristos   {"btp",	{ 2, "", UNKNOWN,		0xf00} },
22898b9484cSchristos   /* read control-stack pointer is another 1-or-2 operand insn. */
22998b9484cSchristos   {"rcsp",	{ 2, "", UNKNOWN,		0x01f} },
23098b9484cSchristos   {"rcsp",	{ 1, "", UNKNOWN,		0x01f} }
23198b9484cSchristos };
23298b9484cSchristos 
23398b9484cSchristos /* end: pyramid.opcode.h */
23498b9484cSchristos /* One day I will have to take the time to find out what operands
23598b9484cSchristos    are valid for these insns, and guess at what they mean.
23698b9484cSchristos 
23798b9484cSchristos    I can't imagine what the "I???" insns (iglob, etc) do.
23898b9484cSchristos 
23998b9484cSchristos    the arithmetic-sounding insns ending in "p" sound awfully like BCD
24098b9484cSchristos    arithmetic insns:
24198b9484cSchristos    	dshlp -> Decimal SHift Left Packed
24298b9484cSchristos 	dshrp -> Decimal SHift Right Packed
24398b9484cSchristos    and cvtlp would be convert long to packed.
24498b9484cSchristos    I have no idea how the operands are interpreted; but having them be
24598b9484cSchristos    a long register with (address, length) of an in-memory packed BCD operand
24698b9484cSchristos    would not be surprising.
24798b9484cSchristos    They are unlikely to be a packed bcd string: 64 bits of long give
24898b9484cSchristos    is only 15 digits+sign, which isn't enough for COBOL.
24998b9484cSchristos  */
25098b9484cSchristos #if 0
25198b9484cSchristos   {"wcsp",	{ 2, "", UNKNOWN,		0x00} }, /*write csp?*/
25298b9484cSchristos   /* The OSx Operating System Porting Guide claims SSL does things
25398b9484cSchristos      with tr12 (a register reserved to it) to do with static block-structure
25498b9484cSchristos      references.  SSL=Set Static Link?  It's "Going away next release". */
25598b9484cSchristos   {"ssl",	{ 2, "", UNKNOWN,		0x00} },
25698b9484cSchristos   {"ccmps",	{ 2, "", UNKNOWN,		0x00} },
25798b9484cSchristos   {"lcd",	{ 2, "", UNKNOWN,		0x00} },
25898b9484cSchristos   {"uemul",	{ 2, "", UNKNOWN,		0x00} }, /*unsigned emul*/
25998b9484cSchristos   {"srf",	{ 2, "", UNKNOWN,		0x00} }, /*Gidget time???*/
26098b9484cSchristos   {"mnegp",	{ 2, "", UNKNOWN,		0x00} }, /move-neg phys?*/
26198b9484cSchristos   {"ldp",	{ 2, "", UNKNOWN,		0x00} }, /*load phys?*/
26298b9484cSchristos   {"ldti",	{ 2, "", UNKNOWN,		0x00} },
26398b9484cSchristos   {"ldb",	{ 2, "", UNKNOWN,		0x00} },
26498b9484cSchristos   {"stp",	{ 2, "", UNKNOWN,		0x00} },
26598b9484cSchristos   {"stti",	{ 2, "", UNKNOWN,		0x00} },
26698b9484cSchristos   {"stb",	{ 2, "", UNKNOWN,		0x00} },
26798b9484cSchristos   {"stu",	{ 2, "", UNKNOWN,		0x00} },
26898b9484cSchristos   {"addp",	{ 2, "", UNKNOWN,		0x00} },
26998b9484cSchristos   {"subp",	{ 2, "", UNKNOWN,		0x00} },
27098b9484cSchristos   {"mulp",	{ 2, "", UNKNOWN,		0x00} },
27198b9484cSchristos   {"divp",	{ 2, "", UNKNOWN,		0x00} },
27298b9484cSchristos   {"dshlp",	{ 2, "", UNKNOWN,		0x00} },  /* dec shl packed? */
27398b9484cSchristos   {"dshrp",	{ 2, "", UNKNOWN,		0x00} }, /* dec shr packed? */
27498b9484cSchristos   {"movs",	{ 2, "", UNKNOWN,		0x00} }, /*move (string?)?*/
27598b9484cSchristos   {"cmpp",	{ 2, "", UNKNOWN,		0x00} }, /* cmp phys?*/
27698b9484cSchristos   {"cmps",	{ 2, "", UNKNOWN,		0x00} }, /* cmp (string?)?*/
27798b9484cSchristos   {"cvtlp",	{ 2, "", UNKNOWN,		0x00} }, /* cvt long to p??*/
27898b9484cSchristos   {"cvtpl",	{ 2, "", UNKNOWN,		0x00} }, /* cvt p to l??*/
27998b9484cSchristos   {"dintr",	{ 2, "", UNKNOWN,		0x00} }, /* ?? intr ?*/
28098b9484cSchristos   {"rphysw",	{ 2, "", UNKNOWN,		0x00} }, /* read phys word?*/
28198b9484cSchristos   {"wphysw",	{ 2, "", UNKNOWN,		0x00} }, /* write phys word?*/
28298b9484cSchristos   {"cmovs",	{ 2, "", UNKNOWN,		0x00} },
28398b9484cSchristos   {"rsubw",	{ 2, "", UNKNOWN,		0x00} },
28498b9484cSchristos   {"bicpsw",	{ 2, "", UNKNOWN,		0x00} }, /* clr bit in psw? */
28598b9484cSchristos   {"bispsw",	{ 2, "", UNKNOWN,		0x00} }, /* set bit in psw? */
28698b9484cSchristos   {"eio",	{ 2, "", UNKNOWN,		0x00} }, /* ?? ?io ? */
28798b9484cSchristos   {"callp",	{ 2, "", UNKNOWN,		0x00} }, /* call phys?*/
28898b9484cSchristos   {"callr",	{ 2, "", UNKNOWN,		0x00} },
28998b9484cSchristos   {"lpcxt",	{ 2, "", UNKNOWN,		0x00} }, /*load proc context*/
29098b9484cSchristos   {"rei",	{ 2, "", UNKNOWN,		0x00} }, /*ret from intrpt*/
29198b9484cSchristos   {"rport",	{ 2, "", UNKNOWN,		0x00} }, /*read-port?*/
29298b9484cSchristos   {"rtod",	{ 2, "", UNKNOWN,		0x00} }, /*read-time-of-day?*/
29398b9484cSchristos   {"ssi",	{ 2, "", UNKNOWN,		0x00} },
29498b9484cSchristos   {"vtpa",	{ 2, "", UNKNOWN,		0x00} }, /*virt-to-phys-addr?*/
29598b9484cSchristos   {"wicl",	{ 2, "", UNKNOWN,		0x00} }, /* write icl ? */
29698b9484cSchristos   {"wport",	{ 2, "", UNKNOWN,		0x00} }, /*write-port?*/
29798b9484cSchristos   {"wtod",	{ 2, "", UNKNOWN,		0x00} }, /*write-time-of-day?*/
29898b9484cSchristos   {"flic",	{ 2, "", UNKNOWN,		0x00} },
29998b9484cSchristos   {"iglob",	{ 2, "", UNKNOWN,		0x00} }, /* I global? */
30098b9484cSchristos   {"iphys",	{ 2, "", UNKNOWN,		0x00} }, /* I physical? */
30198b9484cSchristos   {"ipid",	{ 2, "", UNKNOWN,		0x00} }, /* I pid? */
30298b9484cSchristos   {"ivect",	{ 2, "", UNKNOWN,		0x00} }, /* I vector? */
30398b9484cSchristos   {"lamst",	{ 2, "", UNKNOWN,		0x00} },
30498b9484cSchristos   {"tio",	{ 2, "", UNKNOWN,		0x00} },
30598b9484cSchristos #endif
306