diff options
Diffstat (limited to 'gas/config/tc-m68hc11.c')
-rw-r--r-- | gas/config/tc-m68hc11.c | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/gas/config/tc-m68hc11.c b/gas/config/tc-m68hc11.c index d3e2f8b..a9ac9c7 100644 --- a/gas/config/tc-m68hc11.c +++ b/gas/config/tc-m68hc11.c @@ -189,7 +189,6 @@ struct m9s12xg_opcode_def /* Local functions. */ static register_id reg_name_search (char *); static register_id register_name (void); -static int cmp_opcode (struct m68hc11_opcode *, struct m68hc11_opcode *); static char *print_opcode_format (struct m68hc11_opcode *, int); static char *skip_whites (char *); static int check_range (long, int); @@ -584,12 +583,14 @@ valueT md_section_align (asection *seg, valueT addr) { int align = bfd_section_alignment (seg); - return ((addr + (1 << align) - 1) & -(1 << align)); + return (addr + ((valueT) 1 << align) - 1) & -((valueT) 1 << align); } static int -cmp_opcode (struct m68hc11_opcode *op1, struct m68hc11_opcode *op2) +cmp_opcode (const void *p1, const void *p2) { + const struct m68hc11_opcode *op1 = p1; + const struct m68hc11_opcode *op2 = p2; return strcmp (op1->name, op2->name); } @@ -639,8 +640,7 @@ md_begin (void) } } } - qsort (opcodes, num_opcodes, sizeof (struct m68hc11_opcode), - (int (*) (const void*, const void*)) cmp_opcode); + qsort (opcodes, num_opcodes, sizeof (struct m68hc11_opcode), cmp_opcode); opc = XNEWVEC (struct m68hc11_opcode_def, num_opcodes); m68hc11_opcode_defs = opc; @@ -989,7 +989,7 @@ print_opcode_list (void) printf ("\n"); printf ("%-5.5s ", opcodes->name); - prev_name = (char *) opcodes->name; + prev_name = opcodes->name; } if (fmt[0]) printf (" [%s]", fmt); @@ -1008,7 +1008,7 @@ print_insn_format (char *name) struct m68hc11_opcode *opcode; char buf[128]; - opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, name); + opc = str_hash_find (m68hc11_hash, name); if (opc == NULL) { as_bad (_("Instruction `%s' is not recognized."), name); @@ -1934,9 +1934,8 @@ build_jump_insn (struct m68hc11_opcode *opcode, operand operands[], number_to_chars_bigendian (op, code, 1); number_to_chars_bigendian (op + 1, 0, 1); frag_variant (rs_machine_dependent, 1, 1, - ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF), - operands[0].exp.X_add_symbol, (offsetT) n, - op); + ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF), + operands[0].exp.X_add_symbol, n, op); } else if (current_architecture & cpu6812) { @@ -1945,7 +1944,7 @@ build_jump_insn (struct m68hc11_opcode *opcode, operand operands[], number_to_chars_bigendian (op + 1, 0, 1); frag_var (rs_machine_dependent, 2, 2, ENCODE_RELAX (STATE_CONDITIONAL_BRANCH_6812, STATE_UNDF), - operands[0].exp.X_add_symbol, (offsetT) n, op); + operands[0].exp.X_add_symbol, n, op); } else { @@ -1954,7 +1953,7 @@ build_jump_insn (struct m68hc11_opcode *opcode, operand operands[], number_to_chars_bigendian (op + 1, 0, 1); frag_var (rs_machine_dependent, 3, 3, ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF), - operands[0].exp.X_add_symbol, (offsetT) n, op); + operands[0].exp.X_add_symbol, n, op); } } } @@ -2044,7 +2043,7 @@ build_dbranch_insn (struct m68hc11_opcode *opcode, operand operands[], number_to_chars_bigendian (f + 1, 0, 1); frag_var (rs_machine_dependent, 3, 3, ENCODE_RELAX (STATE_XBCC_BRANCH, STATE_UNDF), - operands[1].exp.X_add_symbol, (offsetT) n, f); + operands[1].exp.X_add_symbol, n, f); } } } @@ -2848,7 +2847,7 @@ md_assemble (char *str) if (current_architecture == cpuxgate) { /* Find the opcode definition given its name. */ - opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, name); + opc = str_hash_find (m68hc11_hash, name); if (opc == NULL) { as_bad (_("Opcode `%s' is not recognized."), name); @@ -3469,7 +3468,7 @@ md_assemble (char *str) } /* Find the opcode definition given its name. */ - opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, name); + opc = str_hash_find (m68hc11_hash, name); /* If it's not recognized, look for 'jbsr' and 'jbxx'. These are pseudo insns for relative branch. For these branches, we always @@ -3477,8 +3476,7 @@ md_assemble (char *str) is given. */ if (opc == NULL && name[0] == 'j' && name[1] == 'b') { - opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, - &name[1]); + opc = str_hash_find (m68hc11_hash, &name[1]); if (opc && (!(opc->format & M6811_OP_JUMP_REL) || (opc->format & M6811_OP_BITMASK))) @@ -3509,8 +3507,7 @@ md_assemble (char *str) { name[nlen++] = TOLOWER (*op_end++); name[nlen] = 0; - opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, - name); + opc = str_hash_find (m68hc11_hash, name); } } } @@ -3838,7 +3835,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) reloc->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_16); else reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); - if (reloc->howto == (reloc_howto_type *) NULL) + if (reloc->howto == NULL) { as_bad_where (fixp->fx_file, fixp->fx_line, _("Relocation %d is not supported by object file format."), @@ -4329,11 +4326,11 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) char *where; long value = * valP; - if (fixP->fx_addsy == (symbolS *) NULL) + if (fixP->fx_addsy == NULL) fixP->fx_done = 1; /* We don't actually support subtracting a symbol. */ - if (fixP->fx_subsy != (symbolS *) NULL) + if (fixP->fx_subsy != NULL) as_bad_subtract (fixP); /* Patch the instruction with the resolved operand. Elf relocation @@ -4350,19 +4347,19 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) switch (fixP->fx_r_type) { case BFD_RELOC_32: - bfd_putb32 ((bfd_vma) value, (unsigned char *) where); + bfd_putb32 (value, where); break; case BFD_RELOC_24: case BFD_RELOC_M68HC11_24: - bfd_putb16 ((bfd_vma) (value & 0x0ffff), (unsigned char *) where); - ((bfd_byte*) where)[2] = ((value >> 16) & 0x0ff); + bfd_putb16 (value & 0x0ffff, where); + where[2] = (value >> 16) & 0xff; break; case BFD_RELOC_16: case BFD_RELOC_16_PCREL: case BFD_RELOC_M68HC11_LO16: - bfd_putb16 ((bfd_vma) value, (unsigned char *) where); + bfd_putb16 (value, where); if (value < -65537 || value > 65535) as_bad_where (fixP->fx_file, fixP->fx_line, _("Value out of 16-bit range.")); @@ -4379,11 +4376,11 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_M68HC11_LO8: case BFD_RELOC_8: case BFD_RELOC_M68HC11_PAGE: - ((bfd_byte *) where)[0] = (bfd_byte) value; + where[0] = value & 0xff; break; case BFD_RELOC_8_PCREL: - ((bfd_byte *) where)[0] = (bfd_byte) value; + where[0] = value & 0xff; if (value < -128 || value > 127) as_bad_where (fixP->fx_file, fixP->fx_line, @@ -4393,8 +4390,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) /* These next two are for XGATE. */ case BFD_RELOC_M68HC12_9_PCREL: - ((bfd_byte *) where)[0] |= (bfd_byte) ((value >>9) & 0x01); - ((bfd_byte *) where)[1] = (bfd_byte) ((value>>1) & 0xff); + where[0] |= (value >> 9) & 0x01; + where[1] = (value >> 1) & 0xff; if (value < -512 || value > 511) as_bad_where (fixP->fx_file, fixP->fx_line, _("Value %ld too large for 9-bit PC-relative branch."), @@ -4402,8 +4399,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) break; case BFD_RELOC_M68HC12_10_PCREL: - ((bfd_byte *) where)[0] |= (bfd_byte) ((value >>9) & 0x03); - ((bfd_byte *) where)[1] = (bfd_byte) ((value>>1) & 0xff); + where[0] |= (value >> 9) & 0x03; + where[1] = (value>> 1) & 0xff; if (value < -1024 || value > 1023) as_bad_where (fixP->fx_file, fixP->fx_line, _("Value %ld too large for 10-bit PC-relative branch."), |