| OLD | NEW |
| 1 /* Print SPARC instructions. | 1 /* Print SPARC instructions. |
| 2 Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | 2 Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
| 3 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 | 3 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012 |
| 4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
| 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) |
| 11 any later version. | 11 any later version. |
| 12 | 12 |
| 13 It is distributed in the hope that it will be useful, but WITHOUT | 13 It is distributed in the hope that it will be useful, but WITHOUT |
| 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | 15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 16 License for more details. | 16 License for more details. |
| 17 | 17 |
| 18 You should have received a copy of the GNU General Public License | 18 You should have received a copy of the GNU General Public License |
| 19 along with this program; if not, write to the Free Software | 19 along with this program; if not, write to the Free Software |
| 20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | 20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
| 21 MA 02110-1301, USA. */ | 21 MA 02110-1301, USA. */ |
| 22 | 22 |
| 23 #include "sysdep.h" |
| 23 #include <stdio.h> | 24 #include <stdio.h> |
| 24 | |
| 25 #include "sysdep.h" | |
| 26 #include "opcode/sparc.h" | 25 #include "opcode/sparc.h" |
| 27 #include "dis-asm.h" | 26 #include "dis-asm.h" |
| 28 #include "libiberty.h" | 27 #include "libiberty.h" |
| 29 #include "opintl.h" | 28 #include "opintl.h" |
| 30 | 29 |
| 31 /* Bitmask of v9 architectures. */ | 30 /* Bitmask of v9 architectures. */ |
| 32 #define MASK_V9 ((1 << SPARC_OPCODE_ARCH_V9) \ | 31 #define MASK_V9 ((1 << SPARC_OPCODE_ARCH_V9) \ |
| 33 | (1 << SPARC_OPCODE_ARCH_V9A) \ | 32 | (1 << SPARC_OPCODE_ARCH_V9A) \ |
| 34 | (1 << SPARC_OPCODE_ARCH_V9B)) | 33 | (1 << SPARC_OPCODE_ARCH_V9B)) |
| 35 /* 1 if INSN is for v9 only. */ | 34 /* 1 if INSN is for v9 only. */ |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 "resv14", "resv15", "resv16", "resv17", "resv18", "resv19", "resv20", | 100 "resv14", "resv15", "resv16", "resv17", "resv18", "resv19", "resv20", |
| 102 "resv21", "resv22", "resv23", "resv24", "resv25", "resv26", "resv27", | 101 "resv21", "resv22", "resv23", "resv24", "resv25", "resv26", "resv27", |
| 103 "resv28", "resv29", "resv30", "hstick_cmpr" | 102 "resv28", "resv29", "resv30", "hstick_cmpr" |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 /* These are ordered according to there register number in | 105 /* These are ordered according to there register number in |
| 107 rd and wr insns (-16). */ | 106 rd and wr insns (-16). */ |
| 108 static char *v9a_asr_reg_names[] = | 107 static char *v9a_asr_reg_names[] = |
| 109 { | 108 { |
| 110 "pcr", "pic", "dcr", "gsr", "set_softint", "clear_softint", | 109 "pcr", "pic", "dcr", "gsr", "set_softint", "clear_softint", |
| 111 "softint", "tick_cmpr", "stick", "stick_cmpr", "resv26", | 110 "softint", "tick_cmpr", "stick", "stick_cmpr", "cfr", |
| 112 "resv27", "cps" | 111 "pause", "cps" |
| 113 }; | 112 }; |
| 114 | 113 |
| 115 /* Macros used to extract instruction fields. Not all fields have | 114 /* Macros used to extract instruction fields. Not all fields have |
| 116 macros defined here, only those which are actually used. */ | 115 macros defined here, only those which are actually used. */ |
| 117 | 116 |
| 118 #define X_RD(i) (((i) >> 25) & 0x1f) | 117 #define X_RD(i) (((i) >> 25) & 0x1f) |
| 119 #define X_RS1(i) (((i) >> 14) & 0x1f) | 118 #define X_RS1(i) (((i) >> 14) & 0x1f) |
| 120 #define X_LDST_I(i) (((i) >> 13) & 1) | 119 #define X_LDST_I(i) (((i) >> 13) & 1) |
| 121 #define X_ASI(i) (((i) >> 5) & 0xff) | 120 #define X_ASI(i) (((i) >> 5) & 0xff) |
| 122 #define X_RS2(i) (((i) >> 0) & 0x1f) | 121 #define X_RS2(i) (((i) >> 0) & 0x1f) |
| 123 #define X_RS3(i) (((i) >> 9) & 0x1f) | 122 #define X_RS3(i) (((i) >> 9) & 0x1f) |
| 124 #define X_IMM(i,n) (((i) >> 0) & ((1 << (n)) - 1)) | 123 #define X_IMM(i,n) (((i) >> 0) & ((1 << (n)) - 1)) |
| 125 #define X_SIMM(i,n) SEX (X_IMM ((i), (n)), (n)) | 124 #define X_SIMM(i,n) SEX (X_IMM ((i), (n)), (n)) |
| 126 #define X_DISP22(i) (((i) >> 0) & 0x3fffff) | 125 #define X_DISP22(i) (((i) >> 0) & 0x3fffff) |
| 127 #define X_IMM22(i) X_DISP22 (i) | 126 #define X_IMM22(i) X_DISP22 (i) |
| 128 #define X_DISP30(i) (((i) >> 0) & 0x3fffffff) | 127 #define X_DISP30(i) (((i) >> 0) & 0x3fffffff) |
| 129 | 128 |
| 130 /* These are for v9. */ | 129 /* These are for v9. */ |
| 131 #define X_DISP16(i) (((((i) >> 20) & 3) << 14) | (((i) >> 0) & 0x3fff)) | 130 #define X_DISP16(i) (((((i) >> 20) & 3) << 14) | (((i) >> 0) & 0x3fff)) |
| 131 #define X_DISP10(i) (((((i) >> 19) & 3) << 8) | (((i) >> 5) & 0xff)) |
| 132 #define X_DISP19(i) (((i) >> 0) & 0x7ffff) | 132 #define X_DISP19(i) (((i) >> 0) & 0x7ffff) |
| 133 #define X_MEMBAR(i) ((i) & 0x7f) | 133 #define X_MEMBAR(i) ((i) & 0x7f) |
| 134 | 134 |
| 135 /* Here is the union which was used to extract instruction fields | 135 /* Here is the union which was used to extract instruction fields |
| 136 before the shift and mask macros were written. | 136 before the shift and mask macros were written. |
| 137 | 137 |
| 138 union sparc_insn | 138 union sparc_insn |
| 139 { | 139 { |
| 140 unsigned long int code; | 140 unsigned long int code; |
| 141 struct | 141 struct |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 if (found_plus) | 696 if (found_plus) |
| 697 imm_added_to_rs1 = 1; | 697 imm_added_to_rs1 = 1; |
| 698 | 698 |
| 699 if (imm <= 9) | 699 if (imm <= 9) |
| 700 (*info->fprintf_func) (stream, "%d", imm); | 700 (*info->fprintf_func) (stream, "%d", imm); |
| 701 else | 701 else |
| 702 (*info->fprintf_func) (stream, "%#x", imm); | 702 (*info->fprintf_func) (stream, "%#x", imm); |
| 703 } | 703 } |
| 704 break; | 704 break; |
| 705 | 705 |
| 706 case ')': /* 5 bit unsigned immediate from RS3. */ |
| 707 (info->fprintf_func) (stream, "%#x", X_RS3 (insn)); |
| 708 break; |
| 709 |
| 706 case 'X': /* 5 bit unsigned immediate. */ | 710 case 'X': /* 5 bit unsigned immediate. */ |
| 707 case 'Y': /* 6 bit unsigned immediate. */ | 711 case 'Y': /* 6 bit unsigned immediate. */ |
| 708 { | 712 { |
| 709 int imm = X_IMM (insn, *s == 'X' ? 5 : 6); | 713 int imm = X_IMM (insn, *s == 'X' ? 5 : 6); |
| 710 | 714 |
| 711 if (imm <= 9) | 715 if (imm <= 9) |
| 712 (info->fprintf_func) (stream, "%d", imm); | 716 (info->fprintf_func) (stream, "%d", imm); |
| 713 else | 717 else |
| 714 (info->fprintf_func) (stream, "%#x", (unsigned) imm); | 718 (info->fprintf_func) (stream, "%#x", (unsigned) imm); |
| 715 } | 719 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 736 (info->fprintf_func) (stream, "|"); | 740 (info->fprintf_func) (stream, "|"); |
| 737 name = sparc_decode_membar (bit); | 741 name = sparc_decode_membar (bit); |
| 738 (info->fprintf_func) (stream, "%s", name); | 742 (info->fprintf_func) (stream, "%s", name); |
| 739 printed_one = 1; | 743 printed_one = 1; |
| 740 } | 744 } |
| 741 bit >>= 1; | 745 bit >>= 1; |
| 742 } | 746 } |
| 743 break; | 747 break; |
| 744 } | 748 } |
| 745 | 749 |
| 750 case '=': |
| 751 info->target = memaddr + SEX (X_DISP10 (insn), 10) * 4; |
| 752 (*info->print_address_func) (info->target, info); |
| 753 break; |
| 754 |
| 746 case 'k': | 755 case 'k': |
| 747 info->target = memaddr + SEX (X_DISP16 (insn), 16) * 4; | 756 info->target = memaddr + SEX (X_DISP16 (insn), 16) * 4; |
| 748 (*info->print_address_func) (info->target, info); | 757 (*info->print_address_func) (info->target, info); |
| 749 break; | 758 break; |
| 750 | 759 |
| 751 case 'G': | 760 case 'G': |
| 752 info->target = memaddr + SEX (X_DISP19 (insn), 19) * 4; | 761 info->target = memaddr + SEX (X_DISP19 (insn), 19) * 4; |
| 753 (*info->print_address_func) (info->target, info); | 762 (*info->print_address_func) (info->target, info); |
| 754 break; | 763 break; |
| 755 | 764 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 } | 1030 } |
| 1022 | 1031 |
| 1023 return sizeof (buffer); | 1032 return sizeof (buffer); |
| 1024 } | 1033 } |
| 1025 } | 1034 } |
| 1026 | 1035 |
| 1027 info->insn_type = dis_noninsn; /* Mark as non-valid instruction. */ | 1036 info->insn_type = dis_noninsn; /* Mark as non-valid instruction. */ |
| 1028 (*info->fprintf_func) (stream, _("unknown")); | 1037 (*info->fprintf_func) (stream, _("unknown")); |
| 1029 return sizeof (buffer); | 1038 return sizeof (buffer); |
| 1030 } | 1039 } |
| OLD | NEW |