| [609] | 1 | /* Table of opcodes for the Motorola M88k family.
|
|---|
| 2 | Copyright 1989, 1990, 1991, 1993, 2001 Free Software Foundation, Inc.
|
|---|
| [10] | 3 |
|
|---|
| 4 | This file is part of GDB and GAS.
|
|---|
| 5 |
|
|---|
| 6 | This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program; if not, write to the Free Software
|
|---|
| 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 19 |
|
|---|
| 20 | /*
|
|---|
| 21 | * Disassembler Instruction Table
|
|---|
| 22 | *
|
|---|
| 23 | * The first field of the table is the opcode field. If an opcode
|
|---|
| 24 | * is specified which has any non-opcode bits on, a system error
|
|---|
| 25 | * will occur when the system attempts the install it into the
|
|---|
| 26 | * instruction table. The second parameter is a pointer to the
|
|---|
| 27 | * instruction mnemonic. Each operand is specified by offset, width,
|
|---|
| 28 | * and type. The offset is the bit number of the least significant
|
|---|
| 29 | * bit of the operand with bit 0 being the least significant bit of
|
|---|
| 30 | * the instruction. The width is the number of bits used to specify
|
|---|
| 31 | * the operand. The type specifies the output format to be used for
|
|---|
| 32 | * the operand. The valid formats are: register, register indirect,
|
|---|
| 33 | * hex constant, and bit field specification. The last field is a
|
|---|
| 34 | * pointer to the next instruction in the linked list. These pointers
|
|---|
| 35 | * are initialized by init_disasm().
|
|---|
| 36 | *
|
|---|
| 37 | * Revision History
|
|---|
| 38 | *
|
|---|
| 39 | * Revision 1.0 11/08/85 Creation date
|
|---|
| 40 | * 1.1 02/05/86 Updated instruction mnemonic table MD
|
|---|
| 41 | * 1.2 06/16/86 Updated SIM_FLAGS for floating point
|
|---|
| 42 | * 1.3 09/20/86 Updated for new encoding
|
|---|
| 43 | * 05/11/89 R. Trawick adapted from Motorola disassembler
|
|---|
| 44 | */
|
|---|
| 45 |
|
|---|
| 46 | #include <stdio.h>
|
|---|
| 47 |
|
|---|
| [609] | 48 | /* Define the number of bits in the primary opcode field of the instruction,
|
|---|
| 49 | the destination field, the source 1 and source 2 fields. */
|
|---|
| [10] | 50 |
|
|---|
| [609] | 51 | /* Size of opcode field. */
|
|---|
| 52 | #define OP 8
|
|---|
| [10] | 53 |
|
|---|
| [609] | 54 | /* Size of destination. */
|
|---|
| 55 | #define DEST 6
|
|---|
| [10] | 56 |
|
|---|
| [609] | 57 | /* Size of source1. */
|
|---|
| 58 | #define SOURCE1 6
|
|---|
| [10] | 59 |
|
|---|
| [609] | 60 | /* Size of source2. */
|
|---|
| 61 | #define SOURCE2 6
|
|---|
| [10] | 62 |
|
|---|
| [609] | 63 | /* Number of registers. */
|
|---|
| 64 | #define REGs 32
|
|---|
| [10] | 65 |
|
|---|
| [609] | 66 | /* Type definitions. */
|
|---|
| [10] | 67 |
|
|---|
| [609] | 68 | typedef unsigned int UINT;
|
|---|
| 69 | #define WORD long
|
|---|
| 70 | #define FLAG unsigned
|
|---|
| 71 | #define STATE short
|
|---|
| [10] | 72 |
|
|---|
| 73 | /* The next four equates define the priorities that the various classes
|
|---|
| 74 | * of instructions have regarding writing results back into registers and
|
|---|
| [609] | 75 | * signalling exceptions. */
|
|---|
| 76 |
|
|---|
| [10] | 77 | /* PMEM is also defined in <sys/param.h> on Delta 88's. Sigh! */
|
|---|
| 78 | #undef PMEM
|
|---|
| 79 |
|
|---|
| [609] | 80 | /* Integer priority. */
|
|---|
| 81 | #define PINT 0
|
|---|
| [10] | 82 |
|
|---|
| [609] | 83 | /* Floating point priority. */
|
|---|
| 84 | #define PFLT 1
|
|---|
| 85 |
|
|---|
| 86 | /* Memory priority. */
|
|---|
| 87 | #define PMEM 2
|
|---|
| 88 |
|
|---|
| 89 | /* Not applicable, instruction doesn't write to regs. */
|
|---|
| 90 | #define NA 3
|
|---|
| 91 |
|
|---|
| 92 | /* Highest of these priorities. */
|
|---|
| 93 | #define HIPRI 3
|
|---|
| 94 |
|
|---|
| [10] | 95 | /* The instruction registers are an artificial mechanism to speed up
|
|---|
| 96 | * simulator execution. In the real processor, an instruction register
|
|---|
| 97 | * is 32 bits wide. In the simulator, the 32 bit instruction is kept in
|
|---|
| 98 | * a structure field called rawop, and the instruction is partially decoded,
|
|---|
| 99 | * and split into various fields and flags which make up the other fields
|
|---|
| 100 | * of the structure.
|
|---|
| 101 | * The partial decode is done when the instructions are initially loaded
|
|---|
| 102 | * into simulator memory. The simulator code memory is not an array of
|
|---|
| 103 | * 32 bit words, but is an array of instruction register structures.
|
|---|
| 104 | * Yes this wastes memory, but it executes much quicker.
|
|---|
| 105 | */
|
|---|
| 106 |
|
|---|
| [609] | 107 | struct IR_FIELDS
|
|---|
| 108 | {
|
|---|
| 109 | unsigned op:OP,
|
|---|
| 110 | dest: DEST,
|
|---|
| 111 | src1: SOURCE1,
|
|---|
| 112 | src2: SOURCE2;
|
|---|
| 113 | int ltncy,
|
|---|
| 114 | extime,
|
|---|
| 115 | /* Writeback priority. */
|
|---|
| 116 | wb_pri;
|
|---|
| 117 | /* Immediate size. */
|
|---|
| 118 | unsigned imm_flags:2,
|
|---|
| 119 | /* Register source 1 used. */
|
|---|
| 120 | rs1_used:1,
|
|---|
| 121 | /* Register source 2 used. */
|
|---|
| 122 | rs2_used:1,
|
|---|
| 123 | /* Register source/dest. used. */
|
|---|
| 124 | rsd_used:1,
|
|---|
| 125 | /* Complement. */
|
|---|
| 126 | c_flag:1,
|
|---|
| 127 | /* Upper half word. */
|
|---|
| 128 | u_flag:1,
|
|---|
| 129 | /* Execute next. */
|
|---|
| 130 | n_flag:1,
|
|---|
| 131 | /* Uses writeback slot. */
|
|---|
| 132 | wb_flag:1,
|
|---|
| 133 | /* Dest size. */
|
|---|
| 134 | dest_64:1,
|
|---|
| 135 | /* Source 1 size. */
|
|---|
| 136 | s1_64:1,
|
|---|
| 137 | /* Source 2 size. */
|
|---|
| 138 | s2_64:1,
|
|---|
| 139 | scale_flag:1,
|
|---|
| 140 | /* Scaled register. */
|
|---|
| 141 | brk_flg:1;
|
|---|
| 142 | };
|
|---|
| [10] | 143 |
|
|---|
| [609] | 144 | struct mem_segs
|
|---|
| 145 | {
|
|---|
| 146 | /* Pointer (returned by calloc) to segment. */
|
|---|
| 147 | struct mem_wrd *seg;
|
|---|
| 148 |
|
|---|
| 149 | /* Base load address from file headers. */
|
|---|
| 150 | unsigned long baseaddr;
|
|---|
| 151 |
|
|---|
| 152 | /* Ending address of segment. */
|
|---|
| 153 | unsigned long endaddr;
|
|---|
| 154 |
|
|---|
| 155 | /* Segment control flags (none defined). */
|
|---|
| 156 | int flags;
|
|---|
| [10] | 157 | };
|
|---|
| 158 |
|
|---|
| 159 | #define MAXSEGS (10) /* max number of segment allowed */
|
|---|
| 160 | #define MEMSEGSIZE (sizeof(struct mem_segs))/* size of mem_segs structure */
|
|---|
| 161 |
|
|---|
| [609] | 162 | #if 0
|
|---|
| [10] | 163 | #define BRK_RD (0x01) /* break on memory read */
|
|---|
| 164 | #define BRK_WR (0x02) /* break on memory write */
|
|---|
| 165 | #define BRK_EXEC (0x04) /* break on execution */
|
|---|
| 166 | #define BRK_CNT (0x08) /* break on terminal count */
|
|---|
| [609] | 167 | #endif
|
|---|
| [10] | 168 |
|
|---|
| [609] | 169 | struct mem_wrd
|
|---|
| 170 | {
|
|---|
| 171 | /* Simulator instruction break down. */
|
|---|
| 172 | struct IR_FIELDS opcode;
|
|---|
| 173 | union {
|
|---|
| 174 | /* Memory element break down. */
|
|---|
| 175 | unsigned long l;
|
|---|
| 176 | unsigned short s[2];
|
|---|
| 177 | unsigned char c[4];
|
|---|
| 178 | } mem;
|
|---|
| [10] | 179 | };
|
|---|
| 180 |
|
|---|
| [609] | 181 | /* Size of each 32 bit memory model. */
|
|---|
| 182 | #define MEMWRDSIZE (sizeof (struct mem_wrd))
|
|---|
| [10] | 183 |
|
|---|
| [609] | 184 | extern struct mem_segs memory[];
|
|---|
| 185 | extern struct PROCESSOR m78000;
|
|---|
| [10] | 186 |
|
|---|
| [609] | 187 | struct PROCESSOR
|
|---|
| 188 | {
|
|---|
| 189 | unsigned WORD
|
|---|
| 190 | /* Execute instruction pointer. */
|
|---|
| 191 | ip,
|
|---|
| 192 | /* Vector base register. */
|
|---|
| 193 | vbr,
|
|---|
| 194 | /* Processor status register. */
|
|---|
| 195 | psr;
|
|---|
| 196 |
|
|---|
| 197 | /* Source 1. */
|
|---|
| 198 | WORD S1bus,
|
|---|
| 199 | /* Source 2. */
|
|---|
| 200 | S2bus,
|
|---|
| 201 | /* Destination. */
|
|---|
| 202 | Dbus,
|
|---|
| 203 | /* Data address bus. */
|
|---|
| 204 | DAbus,
|
|---|
| 205 | ALU,
|
|---|
| 206 | /* Data registers. */
|
|---|
| 207 | Regs[REGs],
|
|---|
| 208 | /* Max clocks before reg is available. */
|
|---|
| 209 | time_left[REGs],
|
|---|
| 210 | /* Writeback priority of reg. */
|
|---|
| 211 | wb_pri[REGs],
|
|---|
| 212 | /* Integer unit control regs. */
|
|---|
| 213 | SFU0_regs[REGs],
|
|---|
| 214 | /* Floating point control regs. */
|
|---|
| 215 | SFU1_regs[REGs],
|
|---|
| 216 | Scoreboard[REGs],
|
|---|
| 217 | Vbr;
|
|---|
| 218 | unsigned WORD scoreboard,
|
|---|
| 219 | Psw,
|
|---|
| 220 | Tpsw;
|
|---|
| 221 | /* Waiting for a jump instruction. */
|
|---|
| 222 | FLAG jump_pending:1;
|
|---|
| 223 | };
|
|---|
| [10] | 224 |
|
|---|
| [609] | 225 | /* Size of immediate field. */
|
|---|
| [10] | 226 |
|
|---|
| [609] | 227 | #define i26bit 1
|
|---|
| 228 | #define i16bit 2
|
|---|
| 229 | #define i10bit 3
|
|---|
| [10] | 230 |
|
|---|
| [609] | 231 | /* Definitions for fields in psr. */
|
|---|
| [10] | 232 |
|
|---|
| [609] | 233 | #define mode 31
|
|---|
| 234 | #define rbo 30
|
|---|
| 235 | #define ser 29
|
|---|
| 236 | #define carry 28
|
|---|
| 237 | #define sf7m 11
|
|---|
| 238 | #define sf6m 10
|
|---|
| 239 | #define sf5m 9
|
|---|
| 240 | #define sf4m 8
|
|---|
| 241 | #define sf3m 7
|
|---|
| 242 | #define sf2m 6
|
|---|
| 243 | #define sf1m 5
|
|---|
| 244 | #define mam 4
|
|---|
| 245 | #define inm 3
|
|---|
| 246 | #define exm 2
|
|---|
| 247 | #define trm 1
|
|---|
| 248 | #define ovfm 0
|
|---|
| [10] | 249 |
|
|---|
| [609] | 250 | /* The 1 clock operations. */
|
|---|
| [10] | 251 |
|
|---|
| [609] | 252 | #define ADDU 1
|
|---|
| 253 | #define ADDC 2
|
|---|
| 254 | #define ADDUC 3
|
|---|
| 255 | #define ADD 4
|
|---|
| [10] | 256 |
|
|---|
| [609] | 257 | #define SUBU ADD+1
|
|---|
| 258 | #define SUBB ADD+2
|
|---|
| 259 | #define SUBUB ADD+3
|
|---|
| 260 | #define SUB ADD+4
|
|---|
| [10] | 261 |
|
|---|
| [609] | 262 | #define AND_ ADD+5
|
|---|
| 263 | #define OR ADD+6
|
|---|
| 264 | #define XOR ADD+7
|
|---|
| 265 | #define CMP ADD+8
|
|---|
| [10] | 266 |
|
|---|
| [609] | 267 | /* Loads. */
|
|---|
| [10] | 268 |
|
|---|
| [609] | 269 | #define LDAB CMP+1
|
|---|
| 270 | #define LDAH CMP+2
|
|---|
| 271 | #define LDA CMP+3
|
|---|
| 272 | #define LDAD CMP+4
|
|---|
| [10] | 273 |
|
|---|
| [609] | 274 | #define LDB LDAD+1
|
|---|
| 275 | #define LDH LDAD+2
|
|---|
| 276 | #define LD LDAD+3
|
|---|
| 277 | #define LDD LDAD+4
|
|---|
| 278 | #define LDBU LDAD+5
|
|---|
| 279 | #define LDHU LDAD+6
|
|---|
| [10] | 280 |
|
|---|
| [609] | 281 | /* Stores. */
|
|---|
| [10] | 282 |
|
|---|
| [609] | 283 | #define STB LDHU+1
|
|---|
| 284 | #define STH LDHU+2
|
|---|
| 285 | #define ST LDHU+3
|
|---|
| 286 | #define STD LDHU+4
|
|---|
| [10] | 287 |
|
|---|
| [609] | 288 | /* Exchange. */
|
|---|
| [10] | 289 |
|
|---|
| [609] | 290 | #define XMEMBU LDHU+5
|
|---|
| 291 | #define XMEM LDHU+6
|
|---|
| [10] | 292 |
|
|---|
| [609] | 293 | /* Branches. */
|
|---|
| [10] | 294 |
|
|---|
| [609] | 295 | #define JSR STD+1
|
|---|
| 296 | #define BSR STD+2
|
|---|
| 297 | #define BR STD+3
|
|---|
| 298 | #define JMP STD+4
|
|---|
| 299 | #define BB1 STD+5
|
|---|
| 300 | #define BB0 STD+6
|
|---|
| 301 | #define RTN STD+7
|
|---|
| 302 | #define BCND STD+8
|
|---|
| [10] | 303 |
|
|---|
| [609] | 304 | /* Traps. */
|
|---|
| [10] | 305 |
|
|---|
| [609] | 306 | #define TB1 BCND+1
|
|---|
| 307 | #define TB0 BCND+2
|
|---|
| 308 | #define TCND BCND+3
|
|---|
| 309 | #define RTE BCND+4
|
|---|
| 310 | #define TBND BCND+5
|
|---|
| [10] | 311 |
|
|---|
| [609] | 312 | /* Misc. */
|
|---|
| [10] | 313 |
|
|---|
| [609] | 314 | #define MUL TBND + 1
|
|---|
| 315 | #define DIV MUL +2
|
|---|
| 316 | #define DIVU MUL +3
|
|---|
| 317 | #define MASK MUL +4
|
|---|
| 318 | #define FF0 MUL +5
|
|---|
| 319 | #define FF1 MUL +6
|
|---|
| 320 | #define CLR MUL +7
|
|---|
| 321 | #define SET MUL +8
|
|---|
| 322 | #define EXT MUL +9
|
|---|
| 323 | #define EXTU MUL +10
|
|---|
| 324 | #define MAK MUL +11
|
|---|
| 325 | #define ROT MUL +12
|
|---|
| [10] | 326 |
|
|---|
| [609] | 327 | /* Control register manipulations. */
|
|---|
| [10] | 328 |
|
|---|
| [609] | 329 | #define LDCR ROT +1
|
|---|
| 330 | #define STCR ROT +2
|
|---|
| 331 | #define XCR ROT +3
|
|---|
| [10] | 332 |
|
|---|
| [609] | 333 | #define FLDCR ROT +4
|
|---|
| 334 | #define FSTCR ROT +5
|
|---|
| 335 | #define FXCR ROT +6
|
|---|
| [10] | 336 |
|
|---|
| [609] | 337 | #define NOP XCR +1
|
|---|
| [10] | 338 |
|
|---|
| [609] | 339 | /* Floating point instructions. */
|
|---|
| [10] | 340 |
|
|---|
| [609] | 341 | #define FADD NOP +1
|
|---|
| 342 | #define FSUB NOP +2
|
|---|
| 343 | #define FMUL NOP +3
|
|---|
| 344 | #define FDIV NOP +4
|
|---|
| 345 | #define FSQRT NOP +5
|
|---|
| 346 | #define FCMP NOP +6
|
|---|
| 347 | #define FIP NOP +7
|
|---|
| 348 | #define FLT NOP +8
|
|---|
| 349 | #define INT NOP +9
|
|---|
| 350 | #define NINT NOP +10
|
|---|
| 351 | #define TRNC NOP +11
|
|---|
| 352 | #define FLDC NOP +12
|
|---|
| 353 | #define FSTC NOP +13
|
|---|
| 354 | #define FXC NOP +14
|
|---|
| [10] | 355 |
|
|---|
| [609] | 356 | #define UEXT(src,off,wid) \
|
|---|
| 357 | ((((unsigned int)(src)) >> (off)) & ((1 << (wid)) - 1))
|
|---|
| [10] | 358 |
|
|---|
| [609] | 359 | #define SEXT(src,off,wid) \
|
|---|
| 360 | (((((int)(src))<<(32 - ((off) + (wid)))) >>(32 - (wid))) )
|
|---|
| [10] | 361 |
|
|---|
| [609] | |
|---|