m68k-parse.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /* m68k-parse.h -- header file for m68k assembler
  2. Copyright (C) 1987-2022 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS 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, or (at your option)
  7. any later version.
  8. GAS 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 GAS; see the file COPYING. If not, write to the Free
  14. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  15. 02110-1301, USA. */
  16. #ifndef M68K_PARSE_H
  17. #define M68K_PARSE_H
  18. /* This header file defines things which are shared between the
  19. operand parser in m68k.y and the m68k assembler proper in
  20. tc-m68k.c. */
  21. /* The various m68k registers. */
  22. /* DATA and ADDR have to be contiguous, so that reg-DATA gives
  23. 0-7==data reg, 8-15==addr reg for operands that take both types.
  24. We don't use forms like "ADDR0 = ADDR" here because this file is
  25. likely to be used on an Apollo, and the broken Apollo compiler
  26. gives an `undefined variable' error if we do that, according to
  27. troy@cbme.unsw.edu.au. */
  28. #define DATA DATA0
  29. #define ADDR ADDR0
  30. #define SP ADDR7
  31. #define BAD BAD0
  32. #define BAC BAC0
  33. enum m68k_register
  34. {
  35. DATA0 = 1, /* 1- 8 == data registers 0-7 */
  36. DATA1,
  37. DATA2,
  38. DATA3,
  39. DATA4,
  40. DATA5,
  41. DATA6,
  42. DATA7,
  43. ADDR0,
  44. ADDR1,
  45. ADDR2,
  46. ADDR3,
  47. ADDR4,
  48. ADDR5,
  49. ADDR6,
  50. ADDR7,
  51. FP0, /* Eight FP registers */
  52. FP1,
  53. FP2,
  54. FP3,
  55. FP4,
  56. FP5,
  57. FP6,
  58. FP7,
  59. COP0, /* Co-processor #0-#7 */
  60. COP1,
  61. COP2,
  62. COP3,
  63. COP4,
  64. COP5,
  65. COP6,
  66. COP7,
  67. PC, /* Program counter */
  68. ZPC, /* Hack for Program space, but 0 addressing */
  69. SR, /* Status Reg */
  70. CCR, /* Condition code Reg */
  71. ACC, /* Accumulator Reg0 (EMAC or ACC on MAC). */
  72. ACC1, /* Accumulator Reg 1 (EMAC). */
  73. ACC2, /* Accumulator Reg 2 (EMAC). */
  74. ACC3, /* Accumulator Reg 3 (EMAC). */
  75. ACCEXT01, /* Accumulator extension 0&1 (EMAC). */
  76. ACCEXT23, /* Accumulator extension 2&3 (EMAC). */
  77. MACSR, /* MAC Status Reg */
  78. MASK, /* Modulus Reg */
  79. /* These have to be grouped together for the movec instruction to work. */
  80. USP, /* User Stack Pointer */
  81. ISP, /* Interrupt stack pointer */
  82. SFC,
  83. DFC,
  84. CACR,
  85. VBR,
  86. CAAR,
  87. CPUCR,
  88. MSP,
  89. ITT0,
  90. ITT1,
  91. DTT0,
  92. DTT1,
  93. MMUSR,
  94. TC,
  95. SRP,
  96. URP,
  97. BUSCR, /* 68060 added these. */
  98. PCR,
  99. ROMBAR, /* mcf5200 added these. */
  100. RAMBAR_ALT, /* Some CF chips have RAMBAR using
  101. RAMBAR0's number */
  102. RAMBAR0,
  103. RAMBAR1,
  104. MMUBAR, /* mcfv4e added these. */
  105. ROMBAR0, /* mcfv4e added these. */
  106. ROMBAR1, /* mcfv4e added these. */
  107. MPCR, EDRAMBAR, SECMBAR, /* mcfv4e added these. */
  108. PCR1U0, PCR1L0, PCR1U1, PCR1L1,/* mcfv4e added these. */
  109. PCR2U0, PCR2L0, PCR2U1, PCR2L1,/* mcfv4e added these. */
  110. PCR3U0, PCR3L0, PCR3U1, PCR3L1,/* mcfv4e added these. */
  111. MBAR0, MBAR1, /* mcfv4e added these. */
  112. ACR0, ACR1, ACR2, ACR3, /* mcf5200 added these. */
  113. ACR4, ACR5, ACR6, ACR7, /* mcf54418 added these. */
  114. FLASHBAR, RAMBAR, /* mcf528x added these. */
  115. MBAR2, /* mcf5249 added this. */
  116. MBAR,
  117. RGPIOBAR, /* mcf54418 added this. */
  118. ASID, /* m5475. */
  119. CAC, /* fido added this. */
  120. MBO,
  121. #define last_movec_reg MBO
  122. /* End of movec ordering constraints. */
  123. FPI,
  124. FPS,
  125. FPC,
  126. DRP, /* 68851 or 68030 MMU regs */
  127. CRP,
  128. CAL,
  129. VAL,
  130. SCC,
  131. AC,
  132. BAD0,
  133. BAD1,
  134. BAD2,
  135. BAD3,
  136. BAD4,
  137. BAD5,
  138. BAD6,
  139. BAD7,
  140. BAC0,
  141. BAC1,
  142. BAC2,
  143. BAC3,
  144. BAC4,
  145. BAC5,
  146. BAC6,
  147. BAC7,
  148. PSR, /* aka MMUSR on 68030 (but not MMUSR on 68040)
  149. and ACUSR on 68ec030 */
  150. PCSR,
  151. IC, /* instruction cache token */
  152. DC, /* data cache token */
  153. NC, /* no cache token */
  154. BC, /* both caches token */
  155. TT0, /* 68030 access control unit regs */
  156. TT1,
  157. ZDATA0, /* suppressed data registers. */
  158. ZDATA1,
  159. ZDATA2,
  160. ZDATA3,
  161. ZDATA4,
  162. ZDATA5,
  163. ZDATA6,
  164. ZDATA7,
  165. ZADDR0, /* suppressed address registers. */
  166. ZADDR1,
  167. ZADDR2,
  168. ZADDR3,
  169. ZADDR4,
  170. ZADDR5,
  171. ZADDR6,
  172. ZADDR7,
  173. /* Upper and lower half of data and address registers. Order *must*
  174. be DATAxL, ADDRxL, DATAxU, ADDRxU. */
  175. DATA0L, /* lower half of data registers */
  176. DATA1L,
  177. DATA2L,
  178. DATA3L,
  179. DATA4L,
  180. DATA5L,
  181. DATA6L,
  182. DATA7L,
  183. ADDR0L, /* lower half of address registers */
  184. ADDR1L,
  185. ADDR2L,
  186. ADDR3L,
  187. ADDR4L,
  188. ADDR5L,
  189. ADDR6L,
  190. ADDR7L,
  191. DATA0U, /* upper half of data registers */
  192. DATA1U,
  193. DATA2U,
  194. DATA3U,
  195. DATA4U,
  196. DATA5U,
  197. DATA6U,
  198. DATA7U,
  199. ADDR0U, /* upper half of address registers */
  200. ADDR1U,
  201. ADDR2U,
  202. ADDR3U,
  203. ADDR4U,
  204. ADDR5U,
  205. ADDR6U,
  206. ADDR7U,
  207. };
  208. /* Size information. */
  209. enum m68k_size
  210. {
  211. /* Unspecified. */
  212. SIZE_UNSPEC,
  213. /* Byte. */
  214. SIZE_BYTE,
  215. /* Word (2 bytes). */
  216. SIZE_WORD,
  217. /* Longword (4 bytes). */
  218. SIZE_LONG
  219. };
  220. /* The structure used to hold information about an index register. */
  221. struct m68k_indexreg
  222. {
  223. /* The index register itself. */
  224. enum m68k_register reg;
  225. /* The size to use. */
  226. enum m68k_size size;
  227. /* The value to scale by. */
  228. int scale;
  229. };
  230. #ifdef OBJ_ELF
  231. /* The type of a PIC expression. */
  232. enum pic_relocation
  233. {
  234. pic_none, /* not pic */
  235. pic_plt_pcrel, /* @PLTPC */
  236. pic_got_pcrel, /* @GOTPC */
  237. pic_plt_off, /* @PLT */
  238. pic_got_off, /* @GOT */
  239. pic_tls_gd, /* @TLSGD */
  240. pic_tls_ldm, /* @TLSLDM */
  241. pic_tls_ldo, /* @TLSLDO */
  242. pic_tls_ie, /* @TLSIE */
  243. pic_tls_le /* @TLSLE */
  244. };
  245. #endif
  246. /* The structure used to hold information about an expression. */
  247. struct m68k_exp
  248. {
  249. /* The size to use. */
  250. enum m68k_size size;
  251. #ifdef OBJ_ELF
  252. /* The type of pic relocation if any. */
  253. enum pic_relocation pic_reloc;
  254. #endif
  255. /* The expression itself. */
  256. expressionS exp;
  257. };
  258. /* The operand modes. */
  259. enum m68k_operand_type
  260. {
  261. IMMED = 1,
  262. ABSL,
  263. DREG,
  264. AREG,
  265. FPREG,
  266. CONTROL,
  267. AINDR,
  268. AINC,
  269. ADEC,
  270. DISP,
  271. BASE,
  272. POST,
  273. PRE,
  274. LSH, /* MAC/EMAC scalefactor '<<'. */
  275. RSH, /* MAC/EMAC scalefactor '>>'. */
  276. REGLST
  277. };
  278. /* The structure used to hold a parsed operand. */
  279. struct m68k_op
  280. {
  281. /* The type of operand. */
  282. enum m68k_operand_type mode;
  283. /* The main register. */
  284. enum m68k_register reg;
  285. /* The register mask for mode REGLST. */
  286. unsigned long mask;
  287. /* An error message. */
  288. const char *error;
  289. /* The index register. */
  290. struct m68k_indexreg index;
  291. /* The displacement. */
  292. struct m68k_exp disp;
  293. /* The outer displacement. */
  294. struct m68k_exp odisp;
  295. /* Is a trailing '&' added to an <ea>? (for MAC/EMAC mask addressing). */
  296. int trailing_ampersand;
  297. };
  298. #endif /* ! defined (M68K_PARSE_H) */
  299. /* The parsing function. */
  300. extern int m68k_ip_op (char *, struct m68k_op *);
  301. /* Whether register prefixes are optional. */
  302. extern int flag_reg_prefix_optional;