more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
+#include "qemu-common.h"
#include "dis-asm.h"
//#include "sysdep.h"
#include "target-cris/opcode-cris.h"
//#include "libiberty.h"
-\f
-#define FALSE 0
-#define TRUE 1
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
/* cris-opc.c -- Table of opcodes for the CRIS processor.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
+along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef NULL
#define NULL (0)
info->private_data = calloc (1, sizeof (struct cris_disasm_data));
disdata = (struct cris_disasm_data *) info->private_data;
if (disdata == NULL)
- return FALSE;
+ return false;
/* Default true. */
disdata->trace_case
|| (strcmp (info->disassembler_options, "nocase") != 0));
disdata->distype = distype;
- return TRUE;
+ return true;
}
static const struct cris_spec_reg *
/* Allocate and clear the opcode-table. */
if (opc_table == NULL)
{
- opc_table = malloc (65536 * sizeof (opc_table[0]));
- if (opc_table == NULL)
- return NULL;
-
- memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
-
- dip_prefixes
- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (dip_prefixes == NULL)
- return NULL;
-
- memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
-
- bdapq_m1_prefixes
- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (bdapq_m1_prefixes == NULL)
- return NULL;
-
- memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
-
- bdapq_m2_prefixes
- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (bdapq_m2_prefixes == NULL)
- return NULL;
-
- memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
-
- bdapq_m4_prefixes
- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (bdapq_m4_prefixes == NULL)
- return NULL;
-
- memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
-
- rest_prefixes
- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (rest_prefixes == NULL)
- return NULL;
-
- memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
+ opc_table = g_new0(const struct cris_opcode *, 65536);
+ dip_prefixes = g_new0(const struct cris_opcode *, 65536);
+ bdapq_m1_prefixes = g_new0(const struct cris_opcode *, 65536);
+ bdapq_m2_prefixes = g_new0(const struct cris_opcode *, 65536);
+ bdapq_m4_prefixes = g_new0(const struct cris_opcode *, 65536);
+ rest_prefixes = g_new0(const struct cris_opcode *, 65536);
}
/* Get the right table if this is a prefix.
If we can't get any data, or we do not get enough data, we print
the error message. */
- for (nbytes = MAX_BYTES_PER_CRIS_INSN; nbytes > 0; nbytes -= 2)
- {
- status = (*info->read_memory_func) (memaddr, buffer, nbytes, info);
- if (status == 0)
- break;
- }
+ nbytes = info->buffer_length;
+ if (nbytes > MAX_BYTES_PER_CRIS_INSN)
+ nbytes = MAX_BYTES_PER_CRIS_INSN;
+ status = (*info->read_memory_func) (memaddr, buffer, nbytes, info);
/* If we did not get all we asked for, then clear the rest.
Hopefully this makes a reproducible result in case of errors. */
}
/* Disassemble, prefixing register names with `$'. CRIS v0..v10. */
-#if 0
static int
print_insn_cris_with_register_prefix (bfd_vma vma,
disassemble_info *info)
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
return -1;
- return print_insn_cris_generic (vma, info, TRUE);
+ return print_insn_cris_generic (vma, info, true);
}
-#endif
/* Disassemble, prefixing register names with `$'. CRIS v32. */
static int
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v32))
return -1;
- return print_insn_cris_generic (vma, info, TRUE);
+ return print_insn_cris_generic (vma, info, true);
}
#if 0
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
return -1;
- return print_insn_cris_generic (vma, info, TRUE);
+ return print_insn_cris_generic (vma, info, true);
}
/* Disassemble, no prefixes on register names. CRIS v0..v10. */
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
return -1;
- return print_insn_cris_generic (vma, info, FALSE);
+ return print_insn_cris_generic (vma, info, false);
}
/* Disassemble, no prefixes on register names. CRIS v32. */
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v32))
return -1;
- return print_insn_cris_generic (vma, info, FALSE);
+ return print_insn_cris_generic (vma, info, false);
}
/* Disassemble, no prefixes on register names.
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
return -1;
- return print_insn_cris_generic (vma, info, FALSE);
+ return print_insn_cris_generic (vma, info, false);
}
#endif
+int
+print_insn_crisv10 (bfd_vma vma,
+ disassemble_info *info)
+{
+ return print_insn_cris_with_register_prefix(vma, info);
+}
+
int
print_insn_crisv32 (bfd_vma vma,
disassemble_info *info)