OLD | NEW |
1 /* Disassembly routines for TMS320C54X architecture | 1 /* Disassembly routines for TMS320C54X architecture |
2 Copyright 1999, 2000, 2001, 2005, 2007, 2009, 2012 | 2 Copyright 1999, 2000, 2001, 2005, 2007, 2009, 2012 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Contributed by Timothy Wall (twall@cygnus.com) | 4 Contributed by Timothy Wall (twall@cygnus.com) |
5 | 5 |
6 This file is part of the GNU opcodes library. | 6 This file is part of the GNU opcodes library. |
7 | 7 |
8 This library is free software; you can redistribute it and/or modify | 8 This library is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 3, or (at your option) | 10 the Free Software Foundation; either version 3, or (at your option) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 else | 162 else |
163 { | 163 { |
164 size = insn->words + has_lkaddr (memdata, insn); | 164 size = insn->words + has_lkaddr (memdata, insn); |
165 } | 165 } |
166 | 166 |
167 return size; | 167 return size; |
168 } | 168 } |
169 | 169 |
170 int | 170 int |
171 print_instruction (info, memaddr, opcode, tm_name, tm_operands, size, ext) | 171 print_instruction (disassemble_info *info, |
172 disassemble_info *info; | 172 » » bfd_vma memaddr, |
173 bfd_vma memaddr; | 173 » » unsigned short opcode, |
174 unsigned short opcode; | 174 » » const char *tm_name, |
175 const char *tm_name; | 175 » » const enum optype tm_operands[], |
176 const enum optype tm_operands[]; | 176 » » int size, |
177 int size; | 177 » » int ext) |
178 int ext; | |
179 { | 178 { |
180 static int n; | 179 static int n; |
181 /* string storage for multiple operands */ | 180 /* string storage for multiple operands */ |
182 char operand[4][64] = { {0},{0},{0},{0}, }; | 181 char operand[4][64] = { {0},{0},{0},{0}, }; |
183 bfd_byte buf[2]; | 182 bfd_byte buf[2]; |
184 unsigned long opcode2 = 0; | 183 unsigned long opcode2 = 0; |
185 unsigned long lkaddr = 0; | 184 unsigned long lkaddr = 0; |
186 enum optype src = OP_None; | 185 enum optype src = OP_None; |
187 enum optype dst = OP_None; | 186 enum optype dst = OP_None; |
188 int i, shift; | 187 int i, shift; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 sprintf (operand[i], "??? (0x%x)", tm_operands[i]); | 461 sprintf (operand[i], "??? (0x%x)", tm_operands[i]); |
463 info->fprintf_func (info->stream, "%s%s", comma, operand[i]); | 462 info->fprintf_func (info->stream, "%s%s", comma, operand[i]); |
464 break; | 463 break; |
465 } | 464 } |
466 comma = next_comma; | 465 comma = next_comma; |
467 } | 466 } |
468 return 1; | 467 return 1; |
469 } | 468 } |
470 | 469 |
471 static int | 470 static int |
472 print_parallel_instruction (info, memaddr, opcode, ptm, size) | 471 print_parallel_instruction (disassemble_info *info, |
473 disassemble_info *info; | 472 » » » bfd_vma memaddr, |
474 bfd_vma memaddr; | 473 » » » unsigned short opcode, |
475 unsigned short opcode; | 474 » » » const insn_template *ptm, |
476 const insn_template *ptm; | 475 » » » int size) |
477 int size; | |
478 { | 476 { |
479 print_instruction (info, memaddr, opcode, | 477 print_instruction (info, memaddr, opcode, |
480 ptm->name, ptm->operand_types, size, 0); | 478 ptm->name, ptm->operand_types, size, 0); |
481 info->fprintf_func (info->stream, " || "); | 479 info->fprintf_func (info->stream, " || "); |
482 return print_instruction (info, memaddr, opcode, | 480 return print_instruction (info, memaddr, opcode, |
483 ptm->parname, ptm->paroperand_types, size, 0); | 481 ptm->parname, ptm->paroperand_types, size, 0); |
484 } | 482 } |
485 | 483 |
486 static int | 484 static int |
487 sprint_dual_address (info, buf, code) | 485 sprint_dual_address (disassemble_info *info ATTRIBUTE_UNUSED, |
488 disassemble_info *info ATTRIBUTE_UNUSED; | 486 » » char buf[], |
489 char buf[]; | 487 » » unsigned short code) |
490 unsigned short code; | |
491 { | 488 { |
492 const char *formats[] = { | 489 const char *formats[] = { |
493 "*ar%d", | 490 "*ar%d", |
494 "*ar%d-", | 491 "*ar%d-", |
495 "*ar%d+", | 492 "*ar%d+", |
496 "*ar%d+0%%", | 493 "*ar%d+0%%", |
497 }; | 494 }; |
498 return sprintf (buf, formats[XMOD (code)], XARX (code)); | 495 return sprintf (buf, formats[XMOD (code)], XARX (code)); |
499 } | 496 } |
500 | 497 |
501 static int | 498 static int |
502 sprint_indirect_address (info, buf, opcode) | 499 sprint_indirect_address (disassemble_info *info ATTRIBUTE_UNUSED, |
503 disassemble_info *info ATTRIBUTE_UNUSED; | 500 » » » char buf[], |
504 char buf[]; | 501 » » » unsigned short opcode) |
505 unsigned short opcode; | |
506 { | 502 { |
507 const char *formats[] = { | 503 const char *formats[] = { |
508 "*ar%d", | 504 "*ar%d", |
509 "*ar%d-", | 505 "*ar%d-", |
510 "*ar%d+", | 506 "*ar%d+", |
511 "*+ar%d", | 507 "*+ar%d", |
512 "*ar%d-0B", | 508 "*ar%d-0B", |
513 "*ar%d-0", | 509 "*ar%d-0", |
514 "*ar%d+0", | 510 "*ar%d+0", |
515 "*ar%d+0B", | 511 "*ar%d+0B", |
516 "*ar%d-%%", | 512 "*ar%d-%%", |
517 "*ar%d-0%%", | 513 "*ar%d-0%%", |
518 "*ar%d+%%", | 514 "*ar%d+%%", |
519 "*ar%d+0%%", | 515 "*ar%d+0%%", |
520 }; | 516 }; |
521 return sprintf (buf, formats[MOD (opcode)], ARF (opcode)); | 517 return sprintf (buf, formats[MOD (opcode)], ARF (opcode)); |
522 } | 518 } |
523 | 519 |
524 static int | 520 static int |
525 sprint_direct_address (info, buf, opcode) | 521 sprint_direct_address (disassemble_info *info ATTRIBUTE_UNUSED, |
526 disassemble_info *info ATTRIBUTE_UNUSED; | 522 » » char buf[], |
527 char buf[]; | 523 » » unsigned short opcode) |
528 unsigned short opcode; | |
529 { | 524 { |
530 /* FIXME -- look up relocation if available */ | 525 /* FIXME -- look up relocation if available */ |
531 return sprintf (buf, "DP+0x%02x", (int) (opcode & 0x7F)); | 526 return sprintf (buf, "DP+0x%02x", (int) (opcode & 0x7F)); |
532 } | 527 } |
533 | 528 |
534 static int | 529 static int |
535 sprint_mmr (info, buf, mmr) | 530 sprint_mmr (disassemble_info *info ATTRIBUTE_UNUSED, |
536 disassemble_info *info ATTRIBUTE_UNUSED; | 531 » char buf[], |
537 char buf[]; | 532 » int mmr) |
538 int mmr; | |
539 { | 533 { |
540 symbol *reg = (symbol *) mmregs; | 534 symbol *reg = (symbol *) mmregs; |
541 while (reg->name != NULL) | 535 while (reg->name != NULL) |
542 { | 536 { |
543 if (mmr == reg->value) | 537 if (mmr == reg->value) |
544 { | 538 { |
545 sprintf (buf, "%s", (reg + 1)->name); | 539 sprintf (buf, "%s", (reg + 1)->name); |
546 return 1; | 540 return 1; |
547 } | 541 } |
548 ++reg; | 542 ++reg; |
549 } | 543 } |
550 sprintf (buf, "MMR(%d)", mmr); /* FIXME -- different targets. */ | 544 sprintf (buf, "MMR(%d)", mmr); /* FIXME -- different targets. */ |
551 return 0; | 545 return 0; |
552 } | 546 } |
553 | 547 |
554 static int | 548 static int |
555 sprint_cc2 (info, buf, opcode) | 549 sprint_cc2 (disassemble_info *info ATTRIBUTE_UNUSED, |
556 disassemble_info *info ATTRIBUTE_UNUSED; | 550 » char *buf, |
557 char *buf; | 551 » unsigned short opcode) |
558 unsigned short opcode; | |
559 { | 552 { |
560 const char *cc2[] = { | 553 const char *cc2[] = { |
561 "??", "??", "ageq", "alt", "aneq", "aeq", "agt", "aleq", | 554 "??", "??", "ageq", "alt", "aneq", "aeq", "agt", "aleq", |
562 "??", "??", "bgeq", "blt", "bneq", "beq", "bgt", "bleq", | 555 "??", "??", "bgeq", "blt", "bneq", "beq", "bgt", "bleq", |
563 }; | 556 }; |
564 return sprintf (buf, "%s", cc2[opcode & 0xF]); | 557 return sprintf (buf, "%s", cc2[opcode & 0xF]); |
565 } | 558 } |
566 | 559 |
567 static int | 560 static int |
568 sprint_condition (info, buf, opcode) | 561 sprint_condition (disassemble_info *info ATTRIBUTE_UNUSED, |
569 disassemble_info *info ATTRIBUTE_UNUSED; | 562 » » char *buf, |
570 char *buf; | 563 » » unsigned short opcode) |
571 unsigned short opcode; | |
572 { | 564 { |
573 char *start = buf; | 565 char *start = buf; |
574 const char *cmp[] = { | 566 const char *cmp[] = { |
575 "??", "??", "geq", "lt", "neq", "eq", "gt", "leq" | 567 "??", "??", "geq", "lt", "neq", "eq", "gt", "leq" |
576 }; | 568 }; |
577 if (opcode & 0x40) | 569 if (opcode & 0x40) |
578 { | 570 { |
579 char acc = (opcode & 0x8) ? 'b' : 'a'; | 571 char acc = (opcode & 0x8) ? 'b' : 'a'; |
580 if (opcode & 0x7) | 572 if (opcode & 0x7) |
581 buf += sprintf (buf, "%c%s%s", acc, cmp[(opcode & 0x7)], | 573 buf += sprintf (buf, "%c%s%s", acc, cmp[(opcode & 0x7)], |
(...skipping 13 matching lines...) Expand all Loading... |
595 (opcode & 0x03) ? ", " : ""); | 587 (opcode & 0x03) ? ", " : ""); |
596 if (opcode & 0x03) | 588 if (opcode & 0x03) |
597 buf += sprintf (buf, "%s", | 589 buf += sprintf (buf, "%s", |
598 ((opcode & 0x03) == 0x03) ? "bio" : "nbio"); | 590 ((opcode & 0x03) == 0x03) ? "bio" : "nbio"); |
599 } | 591 } |
600 else | 592 else |
601 buf += sprintf (buf, "unc"); | 593 buf += sprintf (buf, "unc"); |
602 | 594 |
603 return buf - start; | 595 return buf - start; |
604 } | 596 } |
OLD | NEW |