hppa-dis.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. /* Disassembler for the PA-RISC. Somewhat derived from sparc-pinsn.c.
  2. Copyright (C) 1989-2015 Free Software Foundation, Inc.
  3. Contributed by the Center for Software Science at the
  4. University of Utah (pa-gdb-bugs@cs.utah.edu).
  5. This file is part of the GNU opcodes library.
  6. This library 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 3, or (at your option)
  9. any later version.
  10. It is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  13. License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. #include "sysdep.h"
  19. #include "dis-asm.h"
  20. #include "libhppa.h"
  21. #include "opcode/hppa.h"
  22. /* Integer register names, indexed by the numbers which appear in the
  23. opcodes. */
  24. static const char *const reg_names[] =
  25. {
  26. "flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
  27. "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
  28. "r20", "r21", "r22", "r23", "r24", "r25", "r26", "dp", "ret0", "ret1",
  29. "sp", "r31"
  30. };
  31. /* Floating point register names, indexed by the numbers which appear in the
  32. opcodes. */
  33. static const char *const fp_reg_names[] =
  34. {
  35. "fpsr", "fpe2", "fpe4", "fpe6",
  36. "fr4", "fr5", "fr6", "fr7", "fr8",
  37. "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
  38. "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23",
  39. "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"
  40. };
  41. typedef unsigned int CORE_ADDR;
  42. /* Get at various relevent fields of an instruction word. */
  43. #define MASK_5 0x1f
  44. #define MASK_10 0x3ff
  45. #define MASK_11 0x7ff
  46. #define MASK_14 0x3fff
  47. #define MASK_16 0xffff
  48. #define MASK_21 0x1fffff
  49. /* These macros get bit fields using HP's numbering (MSB = 0). */
  50. #define GET_FIELD(X, FROM, TO) \
  51. ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
  52. #define GET_BIT(X, WHICH) \
  53. GET_FIELD (X, WHICH, WHICH)
  54. /* Some of these have been converted to 2-d arrays because they
  55. consume less storage this way. If the maintenance becomes a
  56. problem, convert them back to const 1-d pointer arrays. */
  57. static const char *const control_reg[] =
  58. {
  59. "rctr", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
  60. "pidr1", "pidr2", "ccr", "sar", "pidr3", "pidr4",
  61. "iva", "eiem", "itmr", "pcsq", "pcoq", "iir", "isr",
  62. "ior", "ipsw", "eirr", "tr0", "tr1", "tr2", "tr3",
  63. "tr4", "tr5", "tr6", "tr7"
  64. };
  65. static const char *const compare_cond_names[] =
  66. {
  67. "", ",=", ",<", ",<=", ",<<", ",<<=", ",sv", ",od",
  68. ",tr", ",<>", ",>=", ",>", ",>>=", ",>>", ",nsv", ",ev"
  69. };
  70. static const char *const compare_cond_64_names[] =
  71. {
  72. ",*", ",*=", ",*<", ",*<=", ",*<<", ",*<<=", ",*sv", ",*od",
  73. ",*tr", ",*<>", ",*>=", ",*>", ",*>>=", ",*>>", ",*nsv", ",*ev"
  74. };
  75. static const char *const cmpib_cond_64_names[] =
  76. {
  77. ",*<<", ",*=", ",*<", ",*<=", ",*>>=", ",*<>", ",*>=", ",*>"
  78. };
  79. static const char *const add_cond_names[] =
  80. {
  81. "", ",=", ",<", ",<=", ",nuv", ",znv", ",sv", ",od",
  82. ",tr", ",<>", ",>=", ",>", ",uv", ",vnz", ",nsv", ",ev"
  83. };
  84. static const char *const add_cond_64_names[] =
  85. {
  86. ",*", ",*=", ",*<", ",*<=", ",*nuv", ",*znv", ",*sv", ",*od",
  87. ",*tr", ",*<>", ",*>=", ",*>", ",*uv", ",*vnz", ",*nsv", ",*ev"
  88. };
  89. static const char *const wide_add_cond_names[] =
  90. {
  91. "", ",=", ",<", ",<=", ",nuv", ",*=", ",*<", ",*<=",
  92. ",tr", ",<>", ",>=", ",>", ",uv", ",*<>", ",*>=", ",*>"
  93. };
  94. static const char *const logical_cond_names[] =
  95. {
  96. "", ",=", ",<", ",<=", 0, 0, 0, ",od",
  97. ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"};
  98. static const char *const logical_cond_64_names[] =
  99. {
  100. ",*", ",*=", ",*<", ",*<=", 0, 0, 0, ",*od",
  101. ",*tr", ",*<>", ",*>=", ",*>", 0, 0, 0, ",*ev"};
  102. static const char *const unit_cond_names[] =
  103. {
  104. "", ",swz", ",sbz", ",shz", ",sdc", ",swc", ",sbc", ",shc",
  105. ",tr", ",nwz", ",nbz", ",nhz", ",ndc", ",nwc", ",nbc", ",nhc"
  106. };
  107. static const char *const unit_cond_64_names[] =
  108. {
  109. ",*", ",*swz", ",*sbz", ",*shz", ",*sdc", ",*swc", ",*sbc", ",*shc",
  110. ",*tr", ",*nwz", ",*nbz", ",*nhz", ",*ndc", ",*nwc", ",*nbc", ",*nhc"
  111. };
  112. static const char *const shift_cond_names[] =
  113. {
  114. "", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev"
  115. };
  116. static const char *const shift_cond_64_names[] =
  117. {
  118. ",*", ",*=", ",*<", ",*od", ",*tr", ",*<>", ",*>=", ",*ev"
  119. };
  120. static const char *const bb_cond_64_names[] =
  121. {
  122. ",*<", ",*>="
  123. };
  124. static const char *const index_compl_names[] = {"", ",m", ",s", ",sm"};
  125. static const char *const short_ldst_compl_names[] = {"", ",ma", "", ",mb"};
  126. static const char *const short_bytes_compl_names[] =
  127. {
  128. "", ",b,m", ",e", ",e,m"
  129. };
  130. static const char *const float_format_names[] = {",sgl", ",dbl", "", ",quad"};
  131. static const char *const fcnv_fixed_names[] = {",w", ",dw", "", ",qw"};
  132. static const char *const fcnv_ufixed_names[] = {",uw", ",udw", "", ",uqw"};
  133. static const char *const float_comp_names[] =
  134. {
  135. ",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>",
  136. ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>",
  137. ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<",
  138. ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true"
  139. };
  140. static const char *const signed_unsigned_names[] = {",u", ",s"};
  141. static const char *const mix_half_names[] = {",l", ",r"};
  142. static const char *const saturation_names[] = {",us", ",ss", 0, ""};
  143. static const char *const read_write_names[] = {",r", ",w"};
  144. static const char *const add_compl_names[] = { 0, "", ",l", ",tsv" };
  145. /* For a bunch of different instructions form an index into a
  146. completer name table. */
  147. #define GET_COMPL(insn) (GET_FIELD (insn, 26, 26) | \
  148. GET_FIELD (insn, 18, 18) << 1)
  149. #define GET_COND(insn) (GET_FIELD ((insn), 16, 18) + \
  150. (GET_FIELD ((insn), 19, 19) ? 8 : 0))
  151. /* Utility function to print registers. Put these first, so gcc's function
  152. inlining can do its stuff. */
  153. #define fputs_filtered(STR,F) (*info->fprintf_func) (info->stream, "%s", STR)
  154. static void
  155. fput_reg (unsigned reg, disassemble_info *info)
  156. {
  157. (*info->fprintf_func) (info->stream, "%s", reg ? reg_names[reg] : "r0");
  158. }
  159. static void
  160. fput_fp_reg (unsigned reg, disassemble_info *info)
  161. {
  162. (*info->fprintf_func) (info->stream, "%s", reg ? fp_reg_names[reg] : "fr0");
  163. }
  164. static void
  165. fput_fp_reg_r (unsigned reg, disassemble_info *info)
  166. {
  167. /* Special case floating point exception registers. */
  168. if (reg < 4)
  169. (*info->fprintf_func) (info->stream, "fpe%d", reg * 2 + 1);
  170. else
  171. (*info->fprintf_func) (info->stream, "%sR",
  172. reg ? fp_reg_names[reg] : "fr0");
  173. }
  174. static void
  175. fput_creg (unsigned reg, disassemble_info *info)
  176. {
  177. (*info->fprintf_func) (info->stream, "%s", control_reg[reg]);
  178. }
  179. /* Print constants with sign. */
  180. static void
  181. fput_const (unsigned num, disassemble_info *info)
  182. {
  183. if ((int) num < 0)
  184. (*info->fprintf_func) (info->stream, "-%x", - (int) num);
  185. else
  186. (*info->fprintf_func) (info->stream, "%x", num);
  187. }
  188. /* Routines to extract various sized constants out of hppa
  189. instructions. */
  190. /* Extract a 3-bit space register number from a be, ble, mtsp or mfsp. */
  191. static int
  192. extract_3 (unsigned word)
  193. {
  194. return GET_FIELD (word, 18, 18) << 2 | GET_FIELD (word, 16, 17);
  195. }
  196. static int
  197. extract_5_load (unsigned word)
  198. {
  199. return low_sign_extend (word >> 16 & MASK_5, 5);
  200. }
  201. /* Extract the immediate field from a st{bhw}s instruction. */
  202. static int
  203. extract_5_store (unsigned word)
  204. {
  205. return low_sign_extend (word & MASK_5, 5);
  206. }
  207. /* Extract the immediate field from a break instruction. */
  208. static unsigned
  209. extract_5r_store (unsigned word)
  210. {
  211. return (word & MASK_5);
  212. }
  213. /* Extract the immediate field from a {sr}sm instruction. */
  214. static unsigned
  215. extract_5R_store (unsigned word)
  216. {
  217. return (word >> 16 & MASK_5);
  218. }
  219. /* Extract the 10 bit immediate field from a {sr}sm instruction. */
  220. static unsigned
  221. extract_10U_store (unsigned word)
  222. {
  223. return (word >> 16 & MASK_10);
  224. }
  225. /* Extract the immediate field from a bb instruction. */
  226. static unsigned
  227. extract_5Q_store (unsigned word)
  228. {
  229. return (word >> 21 & MASK_5);
  230. }
  231. /* Extract an 11 bit immediate field. */
  232. static int
  233. extract_11 (unsigned word)
  234. {
  235. return low_sign_extend (word & MASK_11, 11);
  236. }
  237. /* Extract a 14 bit immediate field. */
  238. static int
  239. extract_14 (unsigned word)
  240. {
  241. return low_sign_extend (word & MASK_14, 14);
  242. }
  243. /* Extract a 16 bit immediate field (PA2.0 wide only). */
  244. static int
  245. extract_16 (unsigned word)
  246. {
  247. int m15, m0, m1;
  248. m0 = GET_BIT (word, 16);
  249. m1 = GET_BIT (word, 17);
  250. m15 = GET_BIT (word, 31);
  251. word = (word >> 1) & 0x1fff;
  252. word = word | (m15 << 15) | ((m15 ^ m0) << 14) | ((m15 ^ m1) << 13);
  253. return sign_extend (word, 16);
  254. }
  255. /* Extract a 21 bit constant. */
  256. static int
  257. extract_21 (unsigned word)
  258. {
  259. int val;
  260. word &= MASK_21;
  261. word <<= 11;
  262. val = GET_FIELD (word, 20, 20);
  263. val <<= 11;
  264. val |= GET_FIELD (word, 9, 19);
  265. val <<= 2;
  266. val |= GET_FIELD (word, 5, 6);
  267. val <<= 5;
  268. val |= GET_FIELD (word, 0, 4);
  269. val <<= 2;
  270. val |= GET_FIELD (word, 7, 8);
  271. return sign_extend (val, 21) << 11;
  272. }
  273. /* Extract a 12 bit constant from branch instructions. */
  274. static int
  275. extract_12 (unsigned word)
  276. {
  277. return sign_extend (GET_FIELD (word, 19, 28)
  278. | GET_FIELD (word, 29, 29) << 10
  279. | (word & 0x1) << 11, 12) << 2;
  280. }
  281. /* Extract a 17 bit constant from branch instructions, returning the
  282. 19 bit signed value. */
  283. static int
  284. extract_17 (unsigned word)
  285. {
  286. return sign_extend (GET_FIELD (word, 19, 28)
  287. | GET_FIELD (word, 29, 29) << 10
  288. | GET_FIELD (word, 11, 15) << 11
  289. | (word & 0x1) << 16, 17) << 2;
  290. }
  291. static int
  292. extract_22 (unsigned word)
  293. {
  294. return sign_extend (GET_FIELD (word, 19, 28)
  295. | GET_FIELD (word, 29, 29) << 10
  296. | GET_FIELD (word, 11, 15) << 11
  297. | GET_FIELD (word, 6, 10) << 16
  298. | (word & 0x1) << 21, 22) << 2;
  299. }
  300. /* Print one instruction. */
  301. int
  302. print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
  303. {
  304. bfd_byte buffer[4];
  305. unsigned int insn, i;
  306. {
  307. int status =
  308. (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info);
  309. if (status != 0)
  310. {
  311. (*info->memory_error_func) (status, memaddr, info);
  312. return -1;
  313. }
  314. }
  315. insn = bfd_getb32 (buffer);
  316. for (i = 0; i < NUMOPCODES; ++i)
  317. {
  318. const struct pa_opcode *opcode = &pa_opcodes[i];
  319. if ((insn & opcode->mask) == opcode->match)
  320. {
  321. const char *s;
  322. #ifndef BFD64
  323. if (opcode->arch == pa20w)
  324. continue;
  325. #endif
  326. (*info->fprintf_func) (info->stream, "%s", opcode->name);
  327. if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))
  328. (*info->fprintf_func) (info->stream, " ");
  329. for (s = opcode->args; *s != '\0'; ++s)
  330. {
  331. switch (*s)
  332. {
  333. case 'x':
  334. fput_reg (GET_FIELD (insn, 11, 15), info);
  335. break;
  336. case 'a':
  337. case 'b':
  338. fput_reg (GET_FIELD (insn, 6, 10), info);
  339. break;
  340. case '^':
  341. fput_creg (GET_FIELD (insn, 6, 10), info);
  342. break;
  343. case 't':
  344. fput_reg (GET_FIELD (insn, 27, 31), info);
  345. break;
  346. /* Handle floating point registers. */
  347. case 'f':
  348. switch (*++s)
  349. {
  350. case 't':
  351. fput_fp_reg (GET_FIELD (insn, 27, 31), info);
  352. break;
  353. case 'T':
  354. if (GET_FIELD (insn, 25, 25))
  355. fput_fp_reg_r (GET_FIELD (insn, 27, 31), info);
  356. else
  357. fput_fp_reg (GET_FIELD (insn, 27, 31), info);
  358. break;
  359. case 'a':
  360. if (GET_FIELD (insn, 25, 25))
  361. fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
  362. else
  363. fput_fp_reg (GET_FIELD (insn, 6, 10), info);
  364. break;
  365. /* 'fA' will not generate a space before the regsiter
  366. name. Normally that is fine. Except that it
  367. causes problems with xmpyu which has no FP format
  368. completer. */
  369. case 'X':
  370. fputs_filtered (" ", info);
  371. /* FALLTHRU */
  372. case 'A':
  373. if (GET_FIELD (insn, 24, 24))
  374. fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
  375. else
  376. fput_fp_reg (GET_FIELD (insn, 6, 10), info);
  377. break;
  378. case 'b':
  379. if (GET_FIELD (insn, 25, 25))
  380. fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
  381. else
  382. fput_fp_reg (GET_FIELD (insn, 11, 15), info);
  383. break;
  384. case 'B':
  385. if (GET_FIELD (insn, 19, 19))
  386. fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
  387. else
  388. fput_fp_reg (GET_FIELD (insn, 11, 15), info);
  389. break;
  390. case 'C':
  391. {
  392. int reg = GET_FIELD (insn, 21, 22);
  393. reg |= GET_FIELD (insn, 16, 18) << 2;
  394. if (GET_FIELD (insn, 23, 23) != 0)
  395. fput_fp_reg_r (reg, info);
  396. else
  397. fput_fp_reg (reg, info);
  398. break;
  399. }
  400. case 'i':
  401. {
  402. int reg = GET_FIELD (insn, 6, 10);
  403. reg |= (GET_FIELD (insn, 26, 26) << 4);
  404. fput_fp_reg (reg, info);
  405. break;
  406. }
  407. case 'j':
  408. {
  409. int reg = GET_FIELD (insn, 11, 15);
  410. reg |= (GET_FIELD (insn, 26, 26) << 4);
  411. fput_fp_reg (reg, info);
  412. break;
  413. }
  414. case 'k':
  415. {
  416. int reg = GET_FIELD (insn, 27, 31);
  417. reg |= (GET_FIELD (insn, 26, 26) << 4);
  418. fput_fp_reg (reg, info);
  419. break;
  420. }
  421. case 'l':
  422. {
  423. int reg = GET_FIELD (insn, 21, 25);
  424. reg |= (GET_FIELD (insn, 26, 26) << 4);
  425. fput_fp_reg (reg, info);
  426. break;
  427. }
  428. case 'm':
  429. {
  430. int reg = GET_FIELD (insn, 16, 20);
  431. reg |= (GET_FIELD (insn, 26, 26) << 4);
  432. fput_fp_reg (reg, info);
  433. break;
  434. }
  435. /* 'fe' will not generate a space before the register
  436. name. Normally that is fine. Except that it
  437. causes problems with fstw fe,y(b) which has no FP
  438. format completer. */
  439. case 'E':
  440. fputs_filtered (" ", info);
  441. /* FALLTHRU */
  442. case 'e':
  443. if (GET_FIELD (insn, 30, 30))
  444. fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
  445. else
  446. fput_fp_reg (GET_FIELD (insn, 11, 15), info);
  447. break;
  448. case 'x':
  449. fput_fp_reg (GET_FIELD (insn, 11, 15), info);
  450. break;
  451. }
  452. break;
  453. case '5':
  454. fput_const (extract_5_load (insn), info);
  455. break;
  456. case 's':
  457. {
  458. int space = GET_FIELD (insn, 16, 17);
  459. /* Zero means implicit addressing, not use of sr0. */
  460. if (space != 0)
  461. (*info->fprintf_func) (info->stream, "sr%d", space);
  462. }
  463. break;
  464. case 'S':
  465. (*info->fprintf_func) (info->stream, "sr%d",
  466. extract_3 (insn));
  467. break;
  468. /* Handle completers. */
  469. case 'c':
  470. switch (*++s)
  471. {
  472. case 'x':
  473. (*info->fprintf_func)
  474. (info->stream, "%s",
  475. index_compl_names[GET_COMPL (insn)]);
  476. break;
  477. case 'X':
  478. (*info->fprintf_func)
  479. (info->stream, "%s ",
  480. index_compl_names[GET_COMPL (insn)]);
  481. break;
  482. case 'm':
  483. (*info->fprintf_func)
  484. (info->stream, "%s",
  485. short_ldst_compl_names[GET_COMPL (insn)]);
  486. break;
  487. case 'M':
  488. (*info->fprintf_func)
  489. (info->stream, "%s ",
  490. short_ldst_compl_names[GET_COMPL (insn)]);
  491. break;
  492. case 'A':
  493. (*info->fprintf_func)
  494. (info->stream, "%s ",
  495. short_bytes_compl_names[GET_COMPL (insn)]);
  496. break;
  497. case 's':
  498. (*info->fprintf_func)
  499. (info->stream, "%s",
  500. short_bytes_compl_names[GET_COMPL (insn)]);
  501. break;
  502. case 'c':
  503. case 'C':
  504. switch (GET_FIELD (insn, 20, 21))
  505. {
  506. case 1:
  507. (*info->fprintf_func) (info->stream, ",bc ");
  508. break;
  509. case 2:
  510. (*info->fprintf_func) (info->stream, ",sl ");
  511. break;
  512. default:
  513. (*info->fprintf_func) (info->stream, " ");
  514. }
  515. break;
  516. case 'd':
  517. switch (GET_FIELD (insn, 20, 21))
  518. {
  519. case 1:
  520. (*info->fprintf_func) (info->stream, ",co ");
  521. break;
  522. default:
  523. (*info->fprintf_func) (info->stream, " ");
  524. }
  525. break;
  526. case 'o':
  527. (*info->fprintf_func) (info->stream, ",o");
  528. break;
  529. case 'g':
  530. (*info->fprintf_func) (info->stream, ",gate");
  531. break;
  532. case 'p':
  533. (*info->fprintf_func) (info->stream, ",l,push");
  534. break;
  535. case 'P':
  536. (*info->fprintf_func) (info->stream, ",pop");
  537. break;
  538. case 'l':
  539. case 'L':
  540. (*info->fprintf_func) (info->stream, ",l");
  541. break;
  542. case 'w':
  543. (*info->fprintf_func)
  544. (info->stream, "%s ",
  545. read_write_names[GET_FIELD (insn, 25, 25)]);
  546. break;
  547. case 'W':
  548. (*info->fprintf_func) (info->stream, ",w ");
  549. break;
  550. case 'r':
  551. if (GET_FIELD (insn, 23, 26) == 5)
  552. (*info->fprintf_func) (info->stream, ",r");
  553. break;
  554. case 'Z':
  555. if (GET_FIELD (insn, 26, 26))
  556. (*info->fprintf_func) (info->stream, ",m ");
  557. else
  558. (*info->fprintf_func) (info->stream, " ");
  559. break;
  560. case 'i':
  561. if (GET_FIELD (insn, 25, 25))
  562. (*info->fprintf_func) (info->stream, ",i");
  563. break;
  564. case 'z':
  565. if (!GET_FIELD (insn, 21, 21))
  566. (*info->fprintf_func) (info->stream, ",z");
  567. break;
  568. case 'a':
  569. (*info->fprintf_func)
  570. (info->stream, "%s",
  571. add_compl_names[GET_FIELD (insn, 20, 21)]);
  572. break;
  573. case 'Y':
  574. (*info->fprintf_func)
  575. (info->stream, ",dc%s",
  576. add_compl_names[GET_FIELD (insn, 20, 21)]);
  577. break;
  578. case 'y':
  579. (*info->fprintf_func)
  580. (info->stream, ",c%s",
  581. add_compl_names[GET_FIELD (insn, 20, 21)]);
  582. break;
  583. case 'v':
  584. if (GET_FIELD (insn, 20, 20))
  585. (*info->fprintf_func) (info->stream, ",tsv");
  586. break;
  587. case 't':
  588. (*info->fprintf_func) (info->stream, ",tc");
  589. if (GET_FIELD (insn, 20, 20))
  590. (*info->fprintf_func) (info->stream, ",tsv");
  591. break;
  592. case 'B':
  593. (*info->fprintf_func) (info->stream, ",db");
  594. if (GET_FIELD (insn, 20, 20))
  595. (*info->fprintf_func) (info->stream, ",tsv");
  596. break;
  597. case 'b':
  598. (*info->fprintf_func) (info->stream, ",b");
  599. if (GET_FIELD (insn, 20, 20))
  600. (*info->fprintf_func) (info->stream, ",tsv");
  601. break;
  602. case 'T':
  603. if (GET_FIELD (insn, 25, 25))
  604. (*info->fprintf_func) (info->stream, ",tc");
  605. break;
  606. case 'S':
  607. /* EXTRD/W has a following condition. */
  608. if (*(s + 1) == '?')
  609. (*info->fprintf_func)
  610. (info->stream, "%s",
  611. signed_unsigned_names[GET_FIELD (insn, 21, 21)]);
  612. else
  613. (*info->fprintf_func)
  614. (info->stream, "%s ",
  615. signed_unsigned_names[GET_FIELD (insn, 21, 21)]);
  616. break;
  617. case 'h':
  618. (*info->fprintf_func)
  619. (info->stream, "%s",
  620. mix_half_names[GET_FIELD (insn, 17, 17)]);
  621. break;
  622. case 'H':
  623. (*info->fprintf_func)
  624. (info->stream, "%s ",
  625. saturation_names[GET_FIELD (insn, 24, 25)]);
  626. break;
  627. case '*':
  628. (*info->fprintf_func)
  629. (info->stream, ",%d%d%d%d ",
  630. GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21),
  631. GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25));
  632. break;
  633. case 'q':
  634. {
  635. int m, a;
  636. m = GET_FIELD (insn, 28, 28);
  637. a = GET_FIELD (insn, 29, 29);
  638. if (m && !a)
  639. fputs_filtered (",ma ", info);
  640. else if (m && a)
  641. fputs_filtered (",mb ", info);
  642. else
  643. fputs_filtered (" ", info);
  644. break;
  645. }
  646. case 'J':
  647. {
  648. int opc = GET_FIELD (insn, 0, 5);
  649. if (opc == 0x16 || opc == 0x1e)
  650. {
  651. if (GET_FIELD (insn, 29, 29) == 0)
  652. fputs_filtered (",ma ", info);
  653. else
  654. fputs_filtered (",mb ", info);
  655. }
  656. else
  657. fputs_filtered (" ", info);
  658. break;
  659. }
  660. case 'e':
  661. {
  662. int opc = GET_FIELD (insn, 0, 5);
  663. if (opc == 0x13 || opc == 0x1b)
  664. {
  665. if (GET_FIELD (insn, 18, 18) == 1)
  666. fputs_filtered (",mb ", info);
  667. else
  668. fputs_filtered (",ma ", info);
  669. }
  670. else if (opc == 0x17 || opc == 0x1f)
  671. {
  672. if (GET_FIELD (insn, 31, 31) == 1)
  673. fputs_filtered (",ma ", info);
  674. else
  675. fputs_filtered (",mb ", info);
  676. }
  677. else
  678. fputs_filtered (" ", info);
  679. break;
  680. }
  681. }
  682. break;
  683. /* Handle conditions. */
  684. case '?':
  685. {
  686. s++;
  687. switch (*s)
  688. {
  689. case 'f':
  690. (*info->fprintf_func)
  691. (info->stream, "%s ",
  692. float_comp_names[GET_FIELD (insn, 27, 31)]);
  693. break;
  694. /* These four conditions are for the set of instructions
  695. which distinguish true/false conditions by opcode
  696. rather than by the 'f' bit (sigh): comb, comib,
  697. addb, addib. */
  698. case 't':
  699. fputs_filtered
  700. (compare_cond_names[GET_FIELD (insn, 16, 18)], info);
  701. break;
  702. case 'n':
  703. fputs_filtered
  704. (compare_cond_names[GET_FIELD (insn, 16, 18)
  705. + GET_FIELD (insn, 4, 4) * 8],
  706. info);
  707. break;
  708. case 'N':
  709. fputs_filtered
  710. (compare_cond_64_names[GET_FIELD (insn, 16, 18)
  711. + GET_FIELD (insn, 2, 2) * 8],
  712. info);
  713. break;
  714. case 'Q':
  715. fputs_filtered
  716. (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)],
  717. info);
  718. break;
  719. case '@':
  720. fputs_filtered
  721. (add_cond_names[GET_FIELD (insn, 16, 18)
  722. + GET_FIELD (insn, 4, 4) * 8],
  723. info);
  724. break;
  725. case 's':
  726. (*info->fprintf_func)
  727. (info->stream, "%s ",
  728. compare_cond_names[GET_COND (insn)]);
  729. break;
  730. case 'S':
  731. (*info->fprintf_func)
  732. (info->stream, "%s ",
  733. compare_cond_64_names[GET_COND (insn)]);
  734. break;
  735. case 'a':
  736. (*info->fprintf_func)
  737. (info->stream, "%s ",
  738. add_cond_names[GET_COND (insn)]);
  739. break;
  740. case 'A':
  741. (*info->fprintf_func)
  742. (info->stream, "%s ",
  743. add_cond_64_names[GET_COND (insn)]);
  744. break;
  745. case 'd':
  746. (*info->fprintf_func)
  747. (info->stream, "%s",
  748. add_cond_names[GET_FIELD (insn, 16, 18)]);
  749. break;
  750. case 'W':
  751. (*info->fprintf_func)
  752. (info->stream, "%s",
  753. wide_add_cond_names[GET_FIELD (insn, 16, 18) +
  754. GET_FIELD (insn, 4, 4) * 8]);
  755. break;
  756. case 'l':
  757. (*info->fprintf_func)
  758. (info->stream, "%s ",
  759. logical_cond_names[GET_COND (insn)]);
  760. break;
  761. case 'L':
  762. (*info->fprintf_func)
  763. (info->stream, "%s ",
  764. logical_cond_64_names[GET_COND (insn)]);
  765. break;
  766. case 'u':
  767. (*info->fprintf_func)
  768. (info->stream, "%s ",
  769. unit_cond_names[GET_COND (insn)]);
  770. break;
  771. case 'U':
  772. (*info->fprintf_func)
  773. (info->stream, "%s ",
  774. unit_cond_64_names[GET_COND (insn)]);
  775. break;
  776. case 'y':
  777. case 'x':
  778. case 'b':
  779. (*info->fprintf_func)
  780. (info->stream, "%s",
  781. shift_cond_names[GET_FIELD (insn, 16, 18)]);
  782. /* If the next character in args is 'n', it will handle
  783. putting out the space. */
  784. if (s[1] != 'n')
  785. (*info->fprintf_func) (info->stream, " ");
  786. break;
  787. case 'X':
  788. (*info->fprintf_func)
  789. (info->stream, "%s ",
  790. shift_cond_64_names[GET_FIELD (insn, 16, 18)]);
  791. break;
  792. case 'B':
  793. (*info->fprintf_func)
  794. (info->stream, "%s",
  795. bb_cond_64_names[GET_FIELD (insn, 16, 16)]);
  796. /* If the next character in args is 'n', it will handle
  797. putting out the space. */
  798. if (s[1] != 'n')
  799. (*info->fprintf_func) (info->stream, " ");
  800. break;
  801. }
  802. break;
  803. }
  804. case 'V':
  805. fput_const (extract_5_store (insn), info);
  806. break;
  807. case 'r':
  808. fput_const (extract_5r_store (insn), info);
  809. break;
  810. case 'R':
  811. fput_const (extract_5R_store (insn), info);
  812. break;
  813. case 'U':
  814. fput_const (extract_10U_store (insn), info);
  815. break;
  816. case 'B':
  817. case 'Q':
  818. fput_const (extract_5Q_store (insn), info);
  819. break;
  820. case 'i':
  821. fput_const (extract_11 (insn), info);
  822. break;
  823. case 'j':
  824. fput_const (extract_14 (insn), info);
  825. break;
  826. case 'k':
  827. fputs_filtered ("L%", info);
  828. fput_const (extract_21 (insn), info);
  829. break;
  830. case '<':
  831. case 'l':
  832. /* 16-bit long disp., PA2.0 wide only. */
  833. fput_const (extract_16 (insn), info);
  834. break;
  835. case 'n':
  836. if (insn & 0x2)
  837. (*info->fprintf_func) (info->stream, ",n ");
  838. else
  839. (*info->fprintf_func) (info->stream, " ");
  840. break;
  841. case 'N':
  842. if ((insn & 0x20) && s[1])
  843. (*info->fprintf_func) (info->stream, ",n ");
  844. else if (insn & 0x20)
  845. (*info->fprintf_func) (info->stream, ",n");
  846. else if (s[1])
  847. (*info->fprintf_func) (info->stream, " ");
  848. break;
  849. case 'w':
  850. (*info->print_address_func)
  851. (memaddr + 8 + extract_12 (insn), info);
  852. break;
  853. case 'W':
  854. /* 17 bit PC-relative branch. */
  855. (*info->print_address_func)
  856. ((memaddr + 8 + extract_17 (insn)), info);
  857. break;
  858. case 'z':
  859. /* 17 bit displacement. This is an offset from a register
  860. so it gets disasssembled as just a number, not any sort
  861. of address. */
  862. fput_const (extract_17 (insn), info);
  863. break;
  864. case 'Z':
  865. /* addil %r1 implicit output. */
  866. fputs_filtered ("r1", info);
  867. break;
  868. case 'Y':
  869. /* be,l %sr0,%r31 implicit output. */
  870. fputs_filtered ("sr0,r31", info);
  871. break;
  872. case '@':
  873. (*info->fprintf_func) (info->stream, "0");
  874. break;
  875. case '.':
  876. (*info->fprintf_func) (info->stream, "%d",
  877. GET_FIELD (insn, 24, 25));
  878. break;
  879. case '*':
  880. (*info->fprintf_func) (info->stream, "%d",
  881. GET_FIELD (insn, 22, 25));
  882. break;
  883. case '!':
  884. fputs_filtered ("sar", info);
  885. break;
  886. case 'p':
  887. (*info->fprintf_func) (info->stream, "%d",
  888. 31 - GET_FIELD (insn, 22, 26));
  889. break;
  890. case '~':
  891. {
  892. int num;
  893. num = GET_FIELD (insn, 20, 20) << 5;
  894. num |= GET_FIELD (insn, 22, 26);
  895. (*info->fprintf_func) (info->stream, "%d", 63 - num);
  896. break;
  897. }
  898. case 'P':
  899. (*info->fprintf_func) (info->stream, "%d",
  900. GET_FIELD (insn, 22, 26));
  901. break;
  902. case 'q':
  903. {
  904. int num;
  905. num = GET_FIELD (insn, 20, 20) << 5;
  906. num |= GET_FIELD (insn, 22, 26);
  907. (*info->fprintf_func) (info->stream, "%d", num);
  908. break;
  909. }
  910. case 'T':
  911. (*info->fprintf_func) (info->stream, "%d",
  912. 32 - GET_FIELD (insn, 27, 31));
  913. break;
  914. case '%':
  915. {
  916. int num;
  917. num = (GET_FIELD (insn, 23, 23) + 1) * 32;
  918. num -= GET_FIELD (insn, 27, 31);
  919. (*info->fprintf_func) (info->stream, "%d", num);
  920. break;
  921. }
  922. case '|':
  923. {
  924. int num;
  925. num = (GET_FIELD (insn, 19, 19) + 1) * 32;
  926. num -= GET_FIELD (insn, 27, 31);
  927. (*info->fprintf_func) (info->stream, "%d", num);
  928. break;
  929. }
  930. case '$':
  931. fput_const (GET_FIELD (insn, 20, 28), info);
  932. break;
  933. case 'A':
  934. fput_const (GET_FIELD (insn, 6, 18), info);
  935. break;
  936. case 'D':
  937. fput_const (GET_FIELD (insn, 6, 31), info);
  938. break;
  939. case 'v':
  940. (*info->fprintf_func) (info->stream, ",%d",
  941. GET_FIELD (insn, 23, 25));
  942. break;
  943. case 'O':
  944. fput_const ((GET_FIELD (insn, 6,20) << 5 |
  945. GET_FIELD (insn, 27, 31)), info);
  946. break;
  947. case 'o':
  948. fput_const (GET_FIELD (insn, 6, 20), info);
  949. break;
  950. case '2':
  951. fput_const ((GET_FIELD (insn, 6, 22) << 5 |
  952. GET_FIELD (insn, 27, 31)), info);
  953. break;
  954. case '1':
  955. fput_const ((GET_FIELD (insn, 11, 20) << 5 |
  956. GET_FIELD (insn, 27, 31)), info);
  957. break;
  958. case '0':
  959. fput_const ((GET_FIELD (insn, 16, 20) << 5 |
  960. GET_FIELD (insn, 27, 31)), info);
  961. break;
  962. case 'u':
  963. (*info->fprintf_func) (info->stream, ",%d",
  964. GET_FIELD (insn, 23, 25));
  965. break;
  966. case 'F':
  967. /* If no destination completer and not before a completer
  968. for fcmp, need a space here. */
  969. if (s[1] == 'G' || s[1] == '?')
  970. fputs_filtered
  971. (float_format_names[GET_FIELD (insn, 19, 20)], info);
  972. else
  973. (*info->fprintf_func)
  974. (info->stream, "%s ",
  975. float_format_names[GET_FIELD (insn, 19, 20)]);
  976. break;
  977. case 'G':
  978. (*info->fprintf_func)
  979. (info->stream, "%s ",
  980. float_format_names[GET_FIELD (insn, 17, 18)]);
  981. break;
  982. case 'H':
  983. if (GET_FIELD (insn, 26, 26) == 1)
  984. (*info->fprintf_func) (info->stream, "%s ",
  985. float_format_names[0]);
  986. else
  987. (*info->fprintf_func) (info->stream, "%s ",
  988. float_format_names[1]);
  989. break;
  990. case 'I':
  991. /* If no destination completer and not before a completer
  992. for fcmp, need a space here. */
  993. if (s[1] == '?')
  994. fputs_filtered
  995. (float_format_names[GET_FIELD (insn, 20, 20)], info);
  996. else
  997. (*info->fprintf_func)
  998. (info->stream, "%s ",
  999. float_format_names[GET_FIELD (insn, 20, 20)]);
  1000. break;
  1001. case 'J':
  1002. fput_const (extract_14 (insn), info);
  1003. break;
  1004. case '#':
  1005. {
  1006. int sign = GET_FIELD (insn, 31, 31);
  1007. int imm10 = GET_FIELD (insn, 18, 27);
  1008. int disp;
  1009. if (sign)
  1010. disp = (-1U << 10) | imm10;
  1011. else
  1012. disp = imm10;
  1013. disp <<= 3;
  1014. fput_const (disp, info);
  1015. break;
  1016. }
  1017. case 'K':
  1018. case 'd':
  1019. {
  1020. int sign = GET_FIELD (insn, 31, 31);
  1021. int imm11 = GET_FIELD (insn, 18, 28);
  1022. int disp;
  1023. if (sign)
  1024. disp = (-1U << 11) | imm11;
  1025. else
  1026. disp = imm11;
  1027. disp <<= 2;
  1028. fput_const (disp, info);
  1029. break;
  1030. }
  1031. case '>':
  1032. case 'y':
  1033. {
  1034. /* 16-bit long disp., PA2.0 wide only. */
  1035. int disp = extract_16 (insn);
  1036. disp &= ~3;
  1037. fput_const (disp, info);
  1038. break;
  1039. }
  1040. case '&':
  1041. {
  1042. /* 16-bit long disp., PA2.0 wide only. */
  1043. int disp = extract_16 (insn);
  1044. disp &= ~7;
  1045. fput_const (disp, info);
  1046. break;
  1047. }
  1048. case '_':
  1049. break; /* Dealt with by '{' */
  1050. case '{':
  1051. {
  1052. int sub = GET_FIELD (insn, 14, 16);
  1053. int df = GET_FIELD (insn, 17, 18);
  1054. int sf = GET_FIELD (insn, 19, 20);
  1055. const char * const * source = float_format_names;
  1056. const char * const * dest = float_format_names;
  1057. char *t = "";
  1058. if (sub == 4)
  1059. {
  1060. fputs_filtered (",UND ", info);
  1061. break;
  1062. }
  1063. if ((sub & 3) == 3)
  1064. t = ",t";
  1065. if ((sub & 3) == 1)
  1066. source = sub & 4 ? fcnv_ufixed_names : fcnv_fixed_names;
  1067. if (sub & 2)
  1068. dest = sub & 4 ? fcnv_ufixed_names : fcnv_fixed_names;
  1069. (*info->fprintf_func) (info->stream, "%s%s%s ",
  1070. t, source[sf], dest[df]);
  1071. break;
  1072. }
  1073. case 'm':
  1074. {
  1075. int y = GET_FIELD (insn, 16, 18);
  1076. if (y != 1)
  1077. fput_const ((y ^ 1) - 1, info);
  1078. }
  1079. break;
  1080. case 'h':
  1081. {
  1082. int cbit;
  1083. cbit = GET_FIELD (insn, 16, 18);
  1084. if (cbit > 0)
  1085. (*info->fprintf_func) (info->stream, ",%d", cbit - 1);
  1086. break;
  1087. }
  1088. case '=':
  1089. {
  1090. int cond = GET_FIELD (insn, 27, 31);
  1091. switch (cond)
  1092. {
  1093. case 0: fputs_filtered (" ", info); break;
  1094. case 1: fputs_filtered ("acc ", info); break;
  1095. case 2: fputs_filtered ("rej ", info); break;
  1096. case 5: fputs_filtered ("acc8 ", info); break;
  1097. case 6: fputs_filtered ("rej8 ", info); break;
  1098. case 9: fputs_filtered ("acc6 ", info); break;
  1099. case 13: fputs_filtered ("acc4 ", info); break;
  1100. case 17: fputs_filtered ("acc2 ", info); break;
  1101. default: break;
  1102. }
  1103. break;
  1104. }
  1105. case 'X':
  1106. (*info->print_address_func)
  1107. (memaddr + 8 + extract_22 (insn), info);
  1108. break;
  1109. case 'L':
  1110. fputs_filtered (",rp", info);
  1111. break;
  1112. default:
  1113. (*info->fprintf_func) (info->stream, "%c", *s);
  1114. break;
  1115. }
  1116. }
  1117. return sizeof (insn);
  1118. }
  1119. }
  1120. (*info->fprintf_func) (info->stream, "#%8x", insn);
  1121. return sizeof (insn);
  1122. }