crx-dis.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /* Disassembler code for CRX.
  2. Copyright (C) 2004-2017 Free Software Foundation, Inc.
  3. Contributed by Tomer Levi, NSC, Israel.
  4. Written by Tomer Levi.
  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 "disassemble.h"
  20. #include "opcode/crx.h"
  21. /* String to print when opcode was not matched. */
  22. #define ILLEGAL "illegal"
  23. /* Escape to 16-bit immediate. */
  24. #define ESCAPE_16_BIT 0xE
  25. /* Extract 'n_bits' from 'a' starting from offset 'offs'. */
  26. #define EXTRACT(a, offs, n_bits) \
  27. (n_bits == 32 ? (((a) >> (offs)) & 0xffffffffL) \
  28. : (((a) >> (offs)) & ((1 << (n_bits)) -1)))
  29. /* Set Bit Mask - a mask to set all bits starting from offset 'offs'. */
  30. #define SBM(offs) ((((1 << (32 - offs)) -1) << (offs)))
  31. typedef unsigned long dwordU;
  32. typedef unsigned short wordU;
  33. typedef struct
  34. {
  35. dwordU val;
  36. int nbits;
  37. } parameter;
  38. /* Structure to hold valid 'cinv' instruction options. */
  39. typedef struct
  40. {
  41. /* Cinv printed string. */
  42. char *str;
  43. /* Value corresponding to the string. */
  44. unsigned int value;
  45. }
  46. cinv_entry;
  47. /* CRX 'cinv' options. */
  48. const cinv_entry crx_cinvs[] =
  49. {
  50. {"[i]", 2}, {"[i,u]", 3}, {"[d]", 4}, {"[d,u]", 5},
  51. {"[d,i]", 6}, {"[d,i,u]", 7}, {"[b]", 8},
  52. {"[b,i]", 10}, {"[b,i,u]", 11}, {"[b,d]", 12},
  53. {"[b,d,u]", 13}, {"[b,d,i]", 14}, {"[b,d,i,u]", 15}
  54. };
  55. /* Enum to distinguish different registers argument types. */
  56. typedef enum REG_ARG_TYPE
  57. {
  58. /* General purpose register (r<N>). */
  59. REG_ARG = 0,
  60. /* User register (u<N>). */
  61. USER_REG_ARG,
  62. /* CO-Processor register (c<N>). */
  63. COP_ARG,
  64. /* CO-Processor special register (cs<N>). */
  65. COPS_ARG
  66. }
  67. REG_ARG_TYPE;
  68. /* Number of valid 'cinv' instruction options. */
  69. int NUMCINVS = ((sizeof crx_cinvs)/(sizeof crx_cinvs[0]));
  70. /* Current opcode table entry we're disassembling. */
  71. const inst *instruction;
  72. /* Current instruction we're disassembling. */
  73. ins currInsn;
  74. /* The current instruction is read into 3 consecutive words. */
  75. wordU words[3];
  76. /* Contains all words in appropriate order. */
  77. ULONGLONG allWords;
  78. /* Holds the current processed argument number. */
  79. int processing_argument_number;
  80. /* Nonzero means a CST4 instruction. */
  81. int cst4flag;
  82. /* Nonzero means the instruction's original size is
  83. incremented (escape sequence is used). */
  84. int size_changed;
  85. static int get_number_of_operands (void);
  86. static argtype getargtype (operand_type);
  87. static int getbits (operand_type);
  88. static char *getregname (reg);
  89. static char *getcopregname (copreg, reg_type);
  90. static char * getprocregname (int);
  91. static char *gettrapstring (unsigned);
  92. static char *getcinvstring (unsigned);
  93. static void getregliststring (int, char *, enum REG_ARG_TYPE);
  94. static wordU get_word_at_PC (bfd_vma, struct disassemble_info *);
  95. static void get_words_at_PC (bfd_vma, struct disassemble_info *);
  96. static unsigned long build_mask (void);
  97. static int powerof2 (int);
  98. static int match_opcode (void);
  99. static void make_instruction (void);
  100. static void print_arguments (ins *, bfd_vma, struct disassemble_info *);
  101. static void print_arg (argument *, bfd_vma, struct disassemble_info *);
  102. /* Retrieve the number of operands for the current assembled instruction. */
  103. static int
  104. get_number_of_operands (void)
  105. {
  106. int i;
  107. for (i = 0; instruction->operands[i].op_type && i < MAX_OPERANDS; i++)
  108. ;
  109. return i;
  110. }
  111. /* Return the bit size for a given operand. */
  112. static int
  113. getbits (operand_type op)
  114. {
  115. if (op < MAX_OPRD)
  116. return crx_optab[op].bit_size;
  117. else
  118. return 0;
  119. }
  120. /* Return the argument type of a given operand. */
  121. static argtype
  122. getargtype (operand_type op)
  123. {
  124. if (op < MAX_OPRD)
  125. return crx_optab[op].arg_type;
  126. else
  127. return nullargs;
  128. }
  129. /* Given the trap index in dispatch table, return its name.
  130. This routine is used when disassembling the 'excp' instruction. */
  131. static char *
  132. gettrapstring (unsigned int trap_index)
  133. {
  134. const trap_entry *trap;
  135. for (trap = crx_traps; trap < crx_traps + NUMTRAPS; trap++)
  136. if (trap->entry == trap_index)
  137. return trap->name;
  138. return ILLEGAL;
  139. }
  140. /* Given a 'cinv' instruction constant operand, return its corresponding string.
  141. This routine is used when disassembling the 'cinv' instruction. */
  142. static char *
  143. getcinvstring (unsigned int num)
  144. {
  145. const cinv_entry *cinv;
  146. for (cinv = crx_cinvs; cinv < (crx_cinvs + NUMCINVS); cinv++)
  147. if (cinv->value == num)
  148. return cinv->str;
  149. return ILLEGAL;
  150. }
  151. /* Given a register enum value, retrieve its name. */
  152. char *
  153. getregname (reg r)
  154. {
  155. const reg_entry * regentry = &crx_regtab[r];
  156. if (regentry->type != CRX_R_REGTYPE)
  157. return ILLEGAL;
  158. else
  159. return regentry->name;
  160. }
  161. /* Given a coprocessor register enum value, retrieve its name. */
  162. char *
  163. getcopregname (copreg r, reg_type type)
  164. {
  165. const reg_entry * regentry;
  166. if (type == CRX_C_REGTYPE)
  167. regentry = &crx_copregtab[r];
  168. else if (type == CRX_CS_REGTYPE)
  169. regentry = &crx_copregtab[r+(cs0-c0)];
  170. else
  171. return ILLEGAL;
  172. return regentry->name;
  173. }
  174. /* Getting a processor register name. */
  175. static char *
  176. getprocregname (int reg_index)
  177. {
  178. const reg_entry *r;
  179. for (r = crx_regtab; r < crx_regtab + NUMREGS; r++)
  180. if (r->image == reg_index)
  181. return r->name;
  182. return "ILLEGAL REGISTER";
  183. }
  184. /* Get the power of two for a given integer. */
  185. static int
  186. powerof2 (int x)
  187. {
  188. int product, i;
  189. for (i = 0, product = 1; i < x; i++)
  190. product *= 2;
  191. return product;
  192. }
  193. /* Transform a register bit mask to a register list. */
  194. void
  195. getregliststring (int mask, char *string, enum REG_ARG_TYPE core_cop)
  196. {
  197. char temp_string[5];
  198. int i;
  199. string[0] = '{';
  200. string[1] = '\0';
  201. /* A zero mask means HI/LO registers. */
  202. if (mask == 0)
  203. {
  204. if (core_cop == USER_REG_ARG)
  205. strcat (string, "ulo,uhi");
  206. else
  207. strcat (string, "lo,hi");
  208. }
  209. else
  210. {
  211. for (i = 0; i < 16; i++)
  212. {
  213. if (mask & 0x1)
  214. {
  215. switch (core_cop)
  216. {
  217. case REG_ARG:
  218. sprintf (temp_string, "r%d", i);
  219. break;
  220. case USER_REG_ARG:
  221. sprintf (temp_string, "u%d", i);
  222. break;
  223. case COP_ARG:
  224. sprintf (temp_string, "c%d", i);
  225. break;
  226. case COPS_ARG:
  227. sprintf (temp_string, "cs%d", i);
  228. break;
  229. default:
  230. break;
  231. }
  232. strcat (string, temp_string);
  233. if (mask & 0xfffe)
  234. strcat (string, ",");
  235. }
  236. mask >>= 1;
  237. }
  238. }
  239. strcat (string, "}");
  240. }
  241. /* START and END are relating 'allWords' struct, which is 48 bits size.
  242. START|--------|END
  243. +---------+---------+---------+---------+
  244. | | V | A | L |
  245. +---------+---------+---------+---------+
  246. 0 16 32 48
  247. words [0] [1] [2] */
  248. static parameter
  249. makelongparameter (ULONGLONG val, int start, int end)
  250. {
  251. parameter p;
  252. p.val = (dwordU) EXTRACT(val, 48 - end, end - start);
  253. p.nbits = end - start;
  254. return p;
  255. }
  256. /* Build a mask of the instruction's 'constant' opcode,
  257. based on the instruction's printing flags. */
  258. static unsigned long
  259. build_mask (void)
  260. {
  261. unsigned int print_flags;
  262. unsigned long mask;
  263. print_flags = instruction->flags & FMT_CRX;
  264. switch (print_flags)
  265. {
  266. case FMT_1:
  267. mask = 0xF0F00000;
  268. break;
  269. case FMT_2:
  270. mask = 0xFFF0FF00;
  271. break;
  272. case FMT_3:
  273. mask = 0xFFF00F00;
  274. break;
  275. case FMT_4:
  276. mask = 0xFFF0F000;
  277. break;
  278. case FMT_5:
  279. mask = 0xFFF0FFF0;
  280. break;
  281. default:
  282. mask = SBM(instruction->match_bits);
  283. break;
  284. }
  285. return mask;
  286. }
  287. /* Search for a matching opcode. Return 1 for success, 0 for failure. */
  288. static int
  289. match_opcode (void)
  290. {
  291. unsigned long mask;
  292. /* The instruction 'constant' opcode doewsn't exceed 32 bits. */
  293. unsigned long doubleWord = (words[1] + (words[0] << 16)) & 0xffffffff;
  294. /* Start searching from end of instruction table. */
  295. instruction = &crx_instruction[NUMOPCODES - 2];
  296. /* Loop over instruction table until a full match is found. */
  297. while (instruction >= crx_instruction)
  298. {
  299. mask = build_mask ();
  300. if ((doubleWord & mask) == BIN(instruction->match, instruction->match_bits))
  301. return 1;
  302. else
  303. instruction--;
  304. }
  305. return 0;
  306. }
  307. /* Set the proper parameter value for different type of arguments. */
  308. static void
  309. make_argument (argument * a, int start_bits)
  310. {
  311. int inst_bit_size, total_size;
  312. parameter p;
  313. if ((instruction->size == 3) && a->size >= 16)
  314. inst_bit_size = 48;
  315. else
  316. inst_bit_size = 32;
  317. switch (a->type)
  318. {
  319. case arg_copr:
  320. case arg_copsr:
  321. p = makelongparameter (allWords, inst_bit_size - (start_bits + a->size),
  322. inst_bit_size - start_bits);
  323. a->cr = p.val;
  324. break;
  325. case arg_r:
  326. p = makelongparameter (allWords, inst_bit_size - (start_bits + a->size),
  327. inst_bit_size - start_bits);
  328. a->r = p.val;
  329. break;
  330. case arg_ic:
  331. p = makelongparameter (allWords, inst_bit_size - (start_bits + a->size),
  332. inst_bit_size - start_bits);
  333. if ((p.nbits == 4) && cst4flag)
  334. {
  335. if (IS_INSN_TYPE (CMPBR_INS) && (p.val == ESCAPE_16_BIT))
  336. {
  337. /* A special case, where the value is actually stored
  338. in the last 4 bits. */
  339. p = makelongparameter (allWords, 44, 48);
  340. /* The size of the instruction should be incremented. */
  341. size_changed = 1;
  342. }
  343. if (p.val == 6)
  344. p.val = -1;
  345. else if (p.val == 13)
  346. p.val = 48;
  347. else if (p.val == 5)
  348. p.val = -4;
  349. else if (p.val == 10)
  350. p.val = 32;
  351. else if (p.val == 11)
  352. p.val = 20;
  353. else if (p.val == 9)
  354. p.val = 16;
  355. }
  356. a->constant = p.val;
  357. break;
  358. case arg_idxr:
  359. a->scale = 0;
  360. total_size = a->size + 10; /* sizeof(rbase + ridx + scl2) = 10. */
  361. p = makelongparameter (allWords, inst_bit_size - total_size,
  362. inst_bit_size - (total_size - 4));
  363. a->r = p.val;
  364. p = makelongparameter (allWords, inst_bit_size - (total_size - 4),
  365. inst_bit_size - (total_size - 8));
  366. a->i_r = p.val;
  367. p = makelongparameter (allWords, inst_bit_size - (total_size - 8),
  368. inst_bit_size - (total_size - 10));
  369. a->scale = p.val;
  370. p = makelongparameter (allWords, inst_bit_size - (total_size - 10),
  371. inst_bit_size);
  372. a->constant = p.val;
  373. break;
  374. case arg_rbase:
  375. p = makelongparameter (allWords, inst_bit_size - (start_bits + 4),
  376. inst_bit_size - start_bits);
  377. a->r = p.val;
  378. break;
  379. case arg_cr:
  380. if (a->size <= 8)
  381. {
  382. p = makelongparameter (allWords, inst_bit_size - (start_bits + 4),
  383. inst_bit_size - start_bits);
  384. a->r = p.val;
  385. /* Case for opc4 r dispu rbase. */
  386. p = makelongparameter (allWords, inst_bit_size - (start_bits + 8),
  387. inst_bit_size - (start_bits + 4));
  388. }
  389. else
  390. {
  391. /* The 'rbase' start_bits is always relative to a 32-bit data type. */
  392. p = makelongparameter (allWords, 32 - (start_bits + 4),
  393. 32 - start_bits);
  394. a->r = p.val;
  395. p = makelongparameter (allWords, 32 - start_bits,
  396. inst_bit_size);
  397. }
  398. if ((p.nbits == 4) && cst4flag)
  399. {
  400. if (instruction->flags & DISPUW4)
  401. p.val *= 2;
  402. else if (instruction->flags & DISPUD4)
  403. p.val *= 4;
  404. }
  405. a->constant = p.val;
  406. break;
  407. case arg_c:
  408. p = makelongparameter (allWords, inst_bit_size - (start_bits + a->size),
  409. inst_bit_size - start_bits);
  410. a->constant = p.val;
  411. break;
  412. default:
  413. break;
  414. }
  415. }
  416. /* Print a single argument. */
  417. static void
  418. print_arg (argument *a, bfd_vma memaddr, struct disassemble_info *info)
  419. {
  420. LONGLONG longdisp, mask;
  421. int sign_flag = 0;
  422. int relative = 0;
  423. bfd_vma number;
  424. int op_index = 0;
  425. char string[200];
  426. PTR stream = info->stream;
  427. fprintf_ftype func = info->fprintf_func;
  428. switch (a->type)
  429. {
  430. case arg_copr:
  431. func (stream, "%s", getcopregname (a->cr, CRX_C_REGTYPE));
  432. break;
  433. case arg_copsr:
  434. func (stream, "%s", getcopregname (a->cr, CRX_CS_REGTYPE));
  435. break;
  436. case arg_r:
  437. if (IS_INSN_MNEMONIC ("mtpr") || IS_INSN_MNEMONIC ("mfpr"))
  438. func (stream, "%s", getprocregname (a->r));
  439. else
  440. func (stream, "%s", getregname (a->r));
  441. break;
  442. case arg_ic:
  443. if (IS_INSN_MNEMONIC ("excp"))
  444. func (stream, "%s", gettrapstring (a->constant));
  445. else if (IS_INSN_MNEMONIC ("cinv"))
  446. func (stream, "%s", getcinvstring (a->constant));
  447. else if (INST_HAS_REG_LIST)
  448. {
  449. REG_ARG_TYPE reg_arg_type = IS_INSN_TYPE (COP_REG_INS) ?
  450. COP_ARG : IS_INSN_TYPE (COPS_REG_INS) ?
  451. COPS_ARG : (instruction->flags & USER_REG) ?
  452. USER_REG_ARG : REG_ARG;
  453. if ((reg_arg_type == COP_ARG) || (reg_arg_type == COPS_ARG))
  454. {
  455. /* Check for proper argument number. */
  456. if (processing_argument_number == 2)
  457. {
  458. getregliststring (a->constant, string, reg_arg_type);
  459. func (stream, "%s", string);
  460. }
  461. else
  462. func (stream, "$0x%lx", a->constant & 0xffffffff);
  463. }
  464. else
  465. {
  466. getregliststring (a->constant, string, reg_arg_type);
  467. func (stream, "%s", string);
  468. }
  469. }
  470. else
  471. func (stream, "$0x%lx", a->constant & 0xffffffff);
  472. break;
  473. case arg_idxr:
  474. func (stream, "0x%lx(%s,%s,%d)", a->constant & 0xffffffff,
  475. getregname (a->r), getregname (a->i_r), powerof2 (a->scale));
  476. break;
  477. case arg_rbase:
  478. func (stream, "(%s)", getregname (a->r));
  479. break;
  480. case arg_cr:
  481. func (stream, "0x%lx(%s)", a->constant & 0xffffffff, getregname (a->r));
  482. if (IS_INSN_TYPE (LD_STOR_INS_INC))
  483. func (stream, "+");
  484. break;
  485. case arg_c:
  486. /* Removed the *2 part as because implicit zeros are no more required.
  487. Have to fix this as this needs a bit of extension in terms of branchins.
  488. Have to add support for cmp and branch instructions. */
  489. if (IS_INSN_TYPE (BRANCH_INS) || IS_INSN_MNEMONIC ("bal")
  490. || IS_INSN_TYPE (CMPBR_INS) || IS_INSN_TYPE (DCR_BRANCH_INS)
  491. || IS_INSN_TYPE (COP_BRANCH_INS))
  492. {
  493. relative = 1;
  494. longdisp = a->constant;
  495. longdisp <<= 1;
  496. switch (a->size)
  497. {
  498. case 8:
  499. case 16:
  500. case 24:
  501. case 32:
  502. mask = ((LONGLONG)1 << a->size) - 1;
  503. if (longdisp & ((LONGLONG)1 << a->size))
  504. {
  505. sign_flag = 1;
  506. longdisp = ~(longdisp) + 1;
  507. }
  508. a->constant = (unsigned long int) (longdisp & mask);
  509. break;
  510. default:
  511. func (stream,
  512. "Wrong offset used in branch/bal instruction");
  513. break;
  514. }
  515. }
  516. /* For branch Neq instruction it is 2*offset + 2. */
  517. else if (IS_INSN_TYPE (BRANCH_NEQ_INS))
  518. a->constant = 2 * a->constant + 2;
  519. else if (IS_INSN_TYPE (LD_STOR_INS_INC)
  520. || IS_INSN_TYPE (LD_STOR_INS)
  521. || IS_INSN_TYPE (STOR_IMM_INS)
  522. || IS_INSN_TYPE (CSTBIT_INS))
  523. {
  524. op_index = instruction->flags & REVERSE_MATCH ? 0 : 1;
  525. if (instruction->operands[op_index].op_type == abs16)
  526. a->constant |= 0xFFFF0000;
  527. }
  528. func (stream, "%s", "0x");
  529. number = (relative ? memaddr : 0)
  530. + (sign_flag ? -a->constant : a->constant);
  531. (*info->print_address_func) (number, info);
  532. break;
  533. default:
  534. break;
  535. }
  536. }
  537. /* Print all the arguments of CURRINSN instruction. */
  538. static void
  539. print_arguments (ins *currentInsn, bfd_vma memaddr, struct disassemble_info *info)
  540. {
  541. int i;
  542. for (i = 0; i < currentInsn->nargs; i++)
  543. {
  544. processing_argument_number = i;
  545. print_arg (&currentInsn->arg[i], memaddr, info);
  546. if (i != currentInsn->nargs - 1)
  547. info->fprintf_func (info->stream, ", ");
  548. }
  549. }
  550. /* Build the instruction's arguments. */
  551. static void
  552. make_instruction (void)
  553. {
  554. int i;
  555. unsigned int shift;
  556. for (i = 0; i < currInsn.nargs; i++)
  557. {
  558. argument a;
  559. memset (&a, 0, sizeof (a));
  560. a.type = getargtype (instruction->operands[i].op_type);
  561. if (instruction->operands[i].op_type == cst4
  562. || instruction->operands[i].op_type == rbase_dispu4)
  563. cst4flag = 1;
  564. a.size = getbits (instruction->operands[i].op_type);
  565. shift = instruction->operands[i].shift;
  566. make_argument (&a, shift);
  567. currInsn.arg[i] = a;
  568. }
  569. /* Calculate instruction size (in bytes). */
  570. currInsn.size = instruction->size + (size_changed ? 1 : 0);
  571. /* Now in bits. */
  572. currInsn.size *= 2;
  573. }
  574. /* Retrieve a single word from a given memory address. */
  575. static wordU
  576. get_word_at_PC (bfd_vma memaddr, struct disassemble_info *info)
  577. {
  578. bfd_byte buffer[4];
  579. int status;
  580. wordU insn = 0;
  581. status = info->read_memory_func (memaddr, buffer, 2, info);
  582. if (status == 0)
  583. insn = (wordU) bfd_getl16 (buffer);
  584. return insn;
  585. }
  586. /* Retrieve multiple words (3) from a given memory address. */
  587. static void
  588. get_words_at_PC (bfd_vma memaddr, struct disassemble_info *info)
  589. {
  590. int i;
  591. bfd_vma mem;
  592. for (i = 0, mem = memaddr; i < 3; i++, mem += 2)
  593. words[i] = get_word_at_PC (mem, info);
  594. allWords =
  595. ((ULONGLONG) words[0] << 32) + ((unsigned long) words[1] << 16) + words[2];
  596. }
  597. /* Prints the instruction by calling print_arguments after proper matching. */
  598. int
  599. print_insn_crx (bfd_vma memaddr, struct disassemble_info *info)
  600. {
  601. int is_decoded; /* Nonzero means instruction has a match. */
  602. /* Initialize global variables. */
  603. cst4flag = 0;
  604. size_changed = 0;
  605. /* Retrieve the encoding from current memory location. */
  606. get_words_at_PC (memaddr, info);
  607. /* Find a matching opcode in table. */
  608. is_decoded = match_opcode ();
  609. /* If found, print the instruction's mnemonic and arguments. */
  610. if (is_decoded > 0 && (words[0] != 0 || words[1] != 0))
  611. {
  612. info->fprintf_func (info->stream, "%s", instruction->mnemonic);
  613. if ((currInsn.nargs = get_number_of_operands ()) != 0)
  614. info->fprintf_func (info->stream, "\t");
  615. make_instruction ();
  616. print_arguments (&currInsn, memaddr, info);
  617. return currInsn.size;
  618. }
  619. /* No match found. */
  620. info->fprintf_func (info->stream,"%s ",ILLEGAL);
  621. return 2;
  622. }