diff options
author | Nick Clifton <nickc@redhat.com> | 2005-07-01 11:16:33 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2005-07-01 11:16:33 +0000 |
commit | 47b0e7ad8c60ea4b45b22ad5cb376f068991bc88 (patch) | |
tree | bb27e86679b3604624116e9a81be6bb3bd7353f2 /opcodes/d30v-dis.c | |
parent | e4e8248d79d8461adf8b0cf22086e85a4c9ee0a4 (diff) | |
download | gdb-47b0e7ad8c60ea4b45b22ad5cb376f068991bc88.zip gdb-47b0e7ad8c60ea4b45b22ad5cb376f068991bc88.tar.gz gdb-47b0e7ad8c60ea4b45b22ad5cb376f068991bc88.tar.bz2 |
Update function declarations to ISO C90 formatting
Diffstat (limited to 'opcodes/d30v-dis.c')
-rw-r--r-- | opcodes/d30v-dis.c | 244 |
1 files changed, 116 insertions, 128 deletions
diff --git a/opcodes/d30v-dis.c b/opcodes/d30v-dis.c index d286e7b..c7385d9 100644 --- a/opcodes/d30v-dis.c +++ b/opcodes/d30v-dis.c @@ -1,19 +1,20 @@ /* Disassemble D30V instructions. - Copyright 1997, 1998, 2000, 2001 Free Software Foundation, Inc. + Copyright 1997, 1998, 2000, 2001, 2005 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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. */ + 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. */ #include <stdio.h> #include "sysdep.h" @@ -23,100 +24,12 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. #define PC_MASK 0xFFFFFFFF -static int lookup_opcode PARAMS ((struct d30v_insn *insn, long num, int is_long)); -static void print_insn PARAMS ((struct disassemble_info *info, bfd_vma memaddr, long long num, - struct d30v_insn *insn, int is_long, int show_ext)); -static int extract_value PARAMS ((long long num, struct d30v_operand *oper, int is_long)); - -int -print_insn_d30v (memaddr, info) - bfd_vma memaddr; - struct disassemble_info *info; -{ - int status, result; - bfd_byte buffer[12]; - unsigned long in1, in2; - struct d30v_insn insn; - long long num; - - insn.form = (struct d30v_format *) NULL; - - info->bytes_per_line = 8; - info->bytes_per_chunk = 4; - info->display_endian = BFD_ENDIAN_BIG; - - status = (*info->read_memory_func) (memaddr, buffer, 4, info); - if (status != 0) - { - (*info->memory_error_func) (status, memaddr, info); - return -1; - } - in1 = bfd_getb32 (buffer); - - status = (*info->read_memory_func) (memaddr + 4, buffer, 4, info); - if (status != 0) - { - info->bytes_per_line = 8; - if (!(result = lookup_opcode (&insn, in1, 0))) - (*info->fprintf_func) (info->stream, ".long\t0x%x", in1); - else - print_insn (info, memaddr, (long long) in1, &insn, 0, result); - return 4; - } - in2 = bfd_getb32 (buffer); - - if (in1 & in2 & FM01) - { - /* LONG instruction. */ - if (!(result = lookup_opcode (&insn, in1, 1))) - { - (*info->fprintf_func) (info->stream, ".long\t0x%x,0x%x", in1, in2); - return 8; - } - num = (long long) in1 << 32 | in2; - print_insn (info, memaddr, num, &insn, 1, result); - } - else - { - num = in1; - if (!(result = lookup_opcode (&insn, in1, 0))) - (*info->fprintf_func) (info->stream, ".long\t0x%x", in1); - else - print_insn (info, memaddr, num, &insn, 0, result); - - switch (((in1 >> 31) << 1) | (in2 >> 31)) - { - case 0: - (*info->fprintf_func) (info->stream, "\t||\t"); - break; - case 1: - (*info->fprintf_func) (info->stream, "\t->\t"); - break; - case 2: - (*info->fprintf_func) (info->stream, "\t<-\t"); - default: - break; - } - - insn.form = (struct d30v_format *) NULL; - num = in2; - if (!(result = lookup_opcode (&insn, in2, 0))) - (*info->fprintf_func) (info->stream, ".long\t0x%x", in2); - else - print_insn (info, memaddr, num, &insn, 0, result); - } - return 8; -} - /* Return 0 if lookup fails, 1 if found and only one form, 2 if found and there are short and long forms. */ static int -lookup_opcode (insn, num, is_long) - struct d30v_insn *insn; - long num; - int is_long; +lookup_opcode (struct d30v_insn *insn, long num, int is_long) { int i = 0, index; struct d30v_format *f; @@ -173,14 +86,39 @@ lookup_opcode (insn, num, is_long) return 1; } +static int +extract_value (long long num, struct d30v_operand *oper, int is_long) +{ + int val; + int shift = 12 - oper->position; + int mask = (0xFFFFFFFF >> (32 - oper->bits)); + + if (is_long) + { + if (oper->bits == 32) + /* Piece together 32-bit constant. */ + val = ((num & 0x3FFFF) + | ((num & 0xFF00000) >> 2) + | ((num & 0x3F00000000LL) >> 6)); + else + val = (num >> (32 + shift)) & mask; + } + else + val = (num >> shift) & mask; + + if (oper->flags & OPERAND_SHIFT) + val <<= 3; + + return val; +} + static void -print_insn (info, memaddr, num, insn, is_long, show_ext) - struct disassemble_info *info; - bfd_vma memaddr; - long long num; - struct d30v_insn *insn; - int is_long; - int show_ext; +print_insn (struct disassemble_info *info, + bfd_vma memaddr, + long long num, + struct d30v_insn *insn, + int is_long, + int show_ext) { int val, opnum, need_comma = 0; struct d30v_operand *oper; @@ -216,6 +154,7 @@ print_insn (info, memaddr, num, insn, is_long, show_ext) while ((opnum = insn->form->operands[opind++]) != 0) { int bits; + oper = (struct d30v_operand *) &d30v_operand_table[opnum]; bits = oper->bits; if (oper->flags & OPERAND_SHIFT) @@ -269,6 +208,7 @@ print_insn (info, memaddr, num, insn, is_long, show_ext) struct d30v_operand *oper3 = (struct d30v_operand *) &d30v_operand_table[insn->form->operands[2]]; int id = extract_value (num, oper3, is_long); + found_control = 1; switch (id) { @@ -357,6 +297,7 @@ print_insn (info, memaddr, num, insn, is_long, show_ext) if (oper->flags & OPERAND_SIGNED) { int max = (1 << (bits - 1)); + if (val & max) { val = -val; @@ -375,33 +316,80 @@ print_insn (info, memaddr, num, insn, is_long, show_ext) (*info->fprintf_func) (info->stream, ")"); } -static int -extract_value (num, oper, is_long) - long long num; - struct d30v_operand *oper; - int is_long; +int +print_insn_d30v (bfd_vma memaddr, struct disassemble_info *info) { - int val; - int shift = 12 - oper->position; - int mask = (0xFFFFFFFF >> (32 - oper->bits)); + int status, result; + bfd_byte buffer[12]; + unsigned long in1, in2; + struct d30v_insn insn; + long long num; - if (is_long) + insn.form = NULL; + + info->bytes_per_line = 8; + info->bytes_per_chunk = 4; + info->display_endian = BFD_ENDIAN_BIG; + + status = (*info->read_memory_func) (memaddr, buffer, 4, info); + if (status != 0) { - if (oper->bits == 32) + (*info->memory_error_func) (status, memaddr, info); + return -1; + } + in1 = bfd_getb32 (buffer); + + status = (*info->read_memory_func) (memaddr + 4, buffer, 4, info); + if (status != 0) + { + info->bytes_per_line = 8; + if (!(result = lookup_opcode (&insn, in1, 0))) + (*info->fprintf_func) (info->stream, ".long\t0x%x", in1); + else + print_insn (info, memaddr, (long long) in1, &insn, 0, result); + return 4; + } + in2 = bfd_getb32 (buffer); + + if (in1 & in2 & FM01) + { + /* LONG instruction. */ + if (!(result = lookup_opcode (&insn, in1, 1))) { - /* Piece together 32-bit constant. */ - val = ((num & 0x3FFFF) - | ((num & 0xFF00000) >> 2) - | ((num & 0x3F00000000LL) >> 6)); + (*info->fprintf_func) (info->stream, ".long\t0x%x,0x%x", in1, in2); + return 8; } - else - val = (num >> (32 + shift)) & mask; + num = (long long) in1 << 32 | in2; + print_insn (info, memaddr, num, &insn, 1, result); } else - val = (num >> shift) & mask; + { + num = in1; + if (!(result = lookup_opcode (&insn, in1, 0))) + (*info->fprintf_func) (info->stream, ".long\t0x%x", in1); + else + print_insn (info, memaddr, num, &insn, 0, result); - if (oper->flags & OPERAND_SHIFT) - val <<= 3; + switch (((in1 >> 31) << 1) | (in2 >> 31)) + { + case 0: + (*info->fprintf_func) (info->stream, "\t||\t"); + break; + case 1: + (*info->fprintf_func) (info->stream, "\t->\t"); + break; + case 2: + (*info->fprintf_func) (info->stream, "\t<-\t"); + default: + break; + } - return val; + insn.form = NULL; + num = in2; + if (!(result = lookup_opcode (&insn, in2, 0))) + (*info->fprintf_func) (info->stream, ".long\t0x%x", in2); + else + print_insn (info, memaddr, num, &insn, 0, result); + } + return 8; } |