m88k.h 11 KB

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