diff options
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 2 | ||||
-rw-r--r-- | gas/config/tc-pj.c | 127 | ||||
-rw-r--r-- | gas/config/tc-tic80.c | 412 |
3 files changed, 260 insertions, 281 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 6accdbb..de4f4f2 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -3,6 +3,8 @@ * config/tc-w65.c: Fix formatting. * config/tc-mn10200.c: Fix formatting. * config/tc-mn10300.c: Likewise. + * config/tc-pj.c: Fix formatting.=0A= + * config/tc-tic80.c: Fix formatting.=0A= 2000-07-17 Frank Ch. Eigler <fche@redhat.com> diff --git a/gas/config/tc-pj.c b/gas/config/tc-pj.c index 4f80309..1a70b03 100644 --- a/gas/config/tc-pj.c +++ b/gas/config/tc-pj.c @@ -19,12 +19,11 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Contributed by Steve Chamberlain of Transmeta, sac@pobox.com */ +/* Contributed by Steve Chamberlain of Transmeta <sac@pobox.com>. */ #include "as.h" #include "opcode/pj.h" - extern const pj_opc_info_t pj_opc_info[512]; const char comment_chars[] = "!/"; @@ -33,7 +32,6 @@ const char line_comment_chars[] = "/!#"; static int pending_reloc; static struct hash_control *opcode_hash_control; - static void little (ignore) @@ -49,14 +47,12 @@ big (ignore) target_big_endian = 1; } - const pseudo_typeS md_pseudo_table[] = { {"ml", little, 0}, {"mb", big, 0}, {0, 0, 0} }; - const char FLT_CHARS[] = "rRsSfFdDxXpP"; const char EXP_CHARS[] = "eE"; @@ -67,7 +63,7 @@ md_operand (op) if (strncmp (input_line_pointer, "%hi16", 5) == 0) { if (pending_reloc) - as_bad (_ ("confusing relocation expressions")); + as_bad (_("confusing relocation expressions")); pending_reloc = BFD_RELOC_PJ_CODE_HI16; input_line_pointer += 5; expression (op); @@ -75,14 +71,14 @@ md_operand (op) if (strncmp (input_line_pointer, "%lo16", 5) == 0) { if (pending_reloc) - as_bad (_ ("confusing relocation expressions")); + as_bad (_("confusing relocation expressions")); pending_reloc = BFD_RELOC_PJ_CODE_LO16; input_line_pointer += 5; expression (op); } } -/* Parse an expression and then restore the input line pointer. */ +/* Parse an expression and then restore the input line pointer. */ static char * parse_exp_save_ilp (s, op) @@ -108,23 +104,22 @@ pj_cons_fix_new_pj (frag, where, nbytes, exp) int nbytes; expressionS *exp; { - static int rv[5][2] = + static int rv[5][2] = { { 0, 0 }, { BFD_RELOC_8, BFD_RELOC_8 }, { BFD_RELOC_PJ_CODE_DIR16, BFD_RELOC_16 }, { 0, 0 }, { BFD_RELOC_PJ_CODE_DIR32, BFD_RELOC_32 }}; - fix_new_exp (frag, where, nbytes, exp, 0, + fix_new_exp (frag, where, nbytes, exp, 0, pending_reloc ? pending_reloc - : rv [nbytes][(now_seg->flags & SEC_CODE) ? 0 : 1]); + : rv[nbytes][(now_seg->flags & SEC_CODE) ? 0 : 1]); pending_reloc = 0; } - /* Turn a reloc description character from the pj-opc.h table into - code which BFD can handle. */ + code which BFD can handle. */ static int c_to_r (x) @@ -151,39 +146,36 @@ c_to_r (x) return 0; } - - - /* Handler for the ipush fake opcode, - turns ipush <foo> into sipush lo16<foo>, sethi hi16<foo>. */ + turns ipush <foo> into sipush lo16<foo>, sethi hi16<foo>. */ static void ipush_code (opcode, str) - pj_opc_info_t *opcode ATTRIBUTE_UNUSED; + pj_opc_info_t *opcode ATTRIBUTE_UNUSED; char *str; { int mod = 0; char *b = frag_more (6); expressionS arg; + b[0] = 0x11; b[3] = 0xed; parse_exp_save_ilp (str + 1, &arg, &mod); if (mod) - as_bad (_ ("can't have relocation for ipush")); - + as_bad (_("can't have relocation for ipush")); - fix_new_exp (frag_now, b - frag_now->fr_literal + 1, 2, - &arg, 0, BFD_RELOC_PJ_CODE_DIR16); + fix_new_exp (frag_now, b - frag_now->fr_literal + 1, 2, + &arg, 0, BFD_RELOC_PJ_CODE_DIR16); fix_new_exp (frag_now, b - frag_now->fr_literal + 4, 2, - &arg, 0, BFD_RELOC_PJ_CODE_HI16); + &arg, 0, BFD_RELOC_PJ_CODE_HI16); } /* Insert names into the opcode table which are really mini macros, - not opcodes. The fakeness is inidicated with an opcode of -1. */ + not opcodes. The fakeness is inidicated with an opcode of -1. */ static void - fake_opcode (name, func) const char * - name; +fake_opcode (name, func) + const char *name; void (*func) (); { pj_opc_info_t *fake = (pj_opc_info_t *) xmalloc (sizeof (pj_opc_info_t)); @@ -194,22 +186,21 @@ static void hash_insert (opcode_hash_control, name, (char *) fake); } - /* Enter another entry into the opcode hash table so the same opcode - can have another name. */ + can have another name. */ + static void - alias (new, old) const char * - new; +alias (new, old) + const char *new; const char *old; { hash_insert (opcode_hash_control, new, (char *) hash_find (opcode_hash_control, old)); } - /* This function is called once, at assembler startup time. It sets up the hash table with all the opcodes in it, and also initializes - some aliases for compatibility with other assemblers. */ + some aliases for compatibility with other assemblers. */ void md_begin () @@ -217,14 +208,14 @@ md_begin () const pj_opc_info_t *opcode; opcode_hash_control = hash_new (); - /* Insert names into hash table */ + /* Insert names into hash table. */ for (opcode = pj_opc_info; opcode->name; opcode++) hash_insert (opcode_hash_control, opcode->name, (char *) opcode); - /* Insert the only fake opcode. */ + /* Insert the only fake opcode. */ fake_opcode ("ipush", ipush_code); - /* Add some aliases for opcode names. */ + /* Add some aliases for opcode names. */ alias ("ifeq_s", "ifeq"); alias ("ifne_s", "ifne"); alias ("if_icmpge_s", "if_icmpge"); @@ -236,10 +227,9 @@ md_begin () bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0); } -/* This is the guts of the machine-dependent assembler. STR points to a - machine dependent instruction. This function is supposed to emit - the frags/bytes it assembles to. - */ +/* This is the guts of the machine-dependent assembler. STR points to + a machine dependent instruction. This function is supposed to emit + the frags/bytes it assembles to. */ void md_assemble (str) @@ -248,7 +238,9 @@ md_assemble (str) unsigned char *op_start; unsigned char *op_end; - // pj_operan_info operand[3]; +#if 0 + pj_operan_info operand[3]; +#endif pj_opc_info_t *opcode; char *output; int idx = 0; @@ -256,37 +248,35 @@ md_assemble (str) int nlen = 0; - /* Drop leading whitespace */ + /* Drop leading whitespace. */ while (*str == ' ') str++; - /* find the op code end */ + /* Find the op code end. */ for (op_start = op_end = (unsigned char *) (str); *op_end && !is_end_of_line[*op_end] && *op_end != ' '; - op_end++) + op_end++) nlen++; pend = *op_end; *op_end = 0; if (nlen == 0) - { - as_bad (_ ("can't find opcode ")); - } + as_bad (_("can't find opcode ")); opcode = (pj_opc_info_t *) hash_find (opcode_hash_control, op_start); *op_end = pend; if (opcode == NULL) { - as_bad (_ ("unknown opcode %s"), op_start); + as_bad (_("unknown opcode %s"), op_start); return; } if (opcode->opcode == -1) { - /* It's a fake opcode.. dig out the args and pretend that was - what we were passed */ + /* It's a fake opcode. Dig out the args and pretend that was + what we were passed. */ ((void (*)()) opcode->name) (opcode, op_end); } else @@ -311,11 +301,11 @@ md_assemble (str) op_end = parse_exp_save_ilp (op_end, &arg); - fix_new_exp (frag_now, + fix_new_exp (frag_now, output - frag_now->fr_literal + idx, ASIZE (opcode->arg[an]), &arg, - PCREL (opcode->arg[an]), + PCREL (opcode->arg[an]), pending_reloc ? pending_reloc : c_to_r (opcode->arg[an])); idx += ASIZE (opcode->arg[an]); @@ -335,10 +325,11 @@ md_assemble (str) } -/* Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ +/* Turn a string in input_line_pointer into a floating point constant + of type type, and store the appropriate bytes in *LITP. The number + of LITTLENUMS emitted is stored in *SIZEP . An error message is + returned, or NULL on OK. */ + char * md_atof (type, litP, sizeP) int type; @@ -362,7 +353,7 @@ md_atof (type, litP, sizeP) default: *sizeP = 0; - return _ ("bad call to md_atof"); + return _("bad call to md_atof"); } t = atof_ieee (input_line_pointer, type, words); @@ -391,7 +382,6 @@ md_atof (type, litP, sizeP) return NULL; } - CONST char *md_shortopts = ""; struct option md_longopts[] = { @@ -408,7 +398,7 @@ size_t md_longopts_size = sizeof (md_longopts); int md_parse_option (c, arg) int c; - char *arg ATTRIBUTE_UNUSED; + char *arg ATTRIBUTE_UNUSED; { switch (c) { @@ -428,17 +418,14 @@ void md_show_usage (stream) FILE *stream; { - fprintf (stream, _ ("\ + fprintf (stream, _("\ PJ options:\n\ -little generate little endian code\n\ -big generate big endian code\n")); } - - /* Apply a fixup to the object file. */ - int md_apply_fix (fixP, valp) fixS *fixP; @@ -449,7 +436,6 @@ md_apply_fix (fixP, valp) long max, min; int shift; - /* adjust_reloc_syms won't convert a reloc against a weak symbol into a reloc against a section, but bfd_install_relocation will screw up if the symbol is defined, so we have to adjust val here @@ -469,7 +455,7 @@ md_apply_fix (fixP, valp) case BFD_RELOC_PJ_CODE_REL16: if (val < -0x8000 || val >= 0x7fff) - as_bad_where (fixP->fx_file, fixP->fx_line, _ ("pcrel too far")); + as_bad_where (fixP->fx_file, fixP->fx_line, _("pcrel too far")); buf[0] |= (val >> 8) & 0xff; buf[1] = val & 0xff; break; @@ -510,7 +496,7 @@ md_apply_fix (fixP, valp) *buf++ = val >> 8; *buf++ = val >> 0; } - else + else { *buf++ = val >> 0; *buf++ = val >> 8; @@ -532,19 +518,18 @@ md_apply_fix (fixP, valp) } break; - default: abort (); } if (max != 0 && (val < min || val > max)) - as_bad_where (fixP->fx_file, fixP->fx_line, _ ("offset out of range")); + as_bad_where (fixP->fx_file, fixP->fx_line, _("offset out of range")); return 0; } /* Put number into target byte order. Always put values in an - executable section into big endian order. */ + executable section into big endian order. */ void md_number_to_chars (ptr, use, nbytes) @@ -558,10 +543,8 @@ md_number_to_chars (ptr, use, nbytes) number_to_chars_littleendian (ptr, use, nbytes); } - - /* Translate internal representation of relocation info to BFD target - format. */ + format. */ arelent * tc_gen_reloc (section, fixp) @@ -583,7 +566,7 @@ tc_gen_reloc (section, fixp) if (rel->howto == NULL) { as_bad_where (fixp->fx_file, fixp->fx_line, - _ ("Cannot represent relocation type %s"), + _("Cannot represent relocation type %s"), bfd_get_reloc_code_name (r_type)); /* Set howto to a garbage value so that we can keep going. */ rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32); diff --git a/gas/config/tc-tic80.c b/gas/config/tc-tic80.c index f31dba3..ce8e416 100644 --- a/gas/config/tc-tic80.c +++ b/gas/config/tc-tic80.c @@ -22,14 +22,15 @@ #include "opcode/tic80.h" #define internal_error(what) \ - as_fatal(_("internal error:%s:%d: %s\n"),__FILE__,__LINE__,what) -#define internal_error_a(what,arg) \ - as_fatal(_("internal error:%s:%d: %s %d\n"),__FILE__,__LINE__,what,arg) + as_fatal(_("internal error:%s:%d: %s\n"), __FILE__, __LINE__, what) +#define internal_error_a(what,arg) \ + as_fatal(_("internal error:%s:%d: %s %d\n"), __FILE__, __LINE__, what, arg) -/* Generic assembler global variables which must be defined by all targets. */ +/* Generic assembler global variables which must be defined by all + targets. */ -/* Characters which always start a comment. */ +/* Characters which always start a comment. */ const char comment_chars[] = ";"; /* Characters which start a comment at the beginning of a line. */ @@ -37,14 +38,14 @@ const char line_comment_chars[] = ";*#"; /* Characters which may be used to separate multiple commands on a single line. The semicolon is such a character by default and should not be - explicitly listed. */ + explicitly listed. */ const char line_separator_chars[] = ""; -/* Characters which are used to indicate an exponent in a floating +/* Characters which are used to indicate an exponent in a floating point number. */ const char EXP_CHARS[] = "eE"; -/* Characters which mean that a number is a floating point constant, +/* Characters which mean that a number is a floating point constant, as in 0f1.0. */ const char FLT_CHARS[] = "fF"; @@ -53,17 +54,17 @@ const char FLT_CHARS[] = "fF"; pseudo-op name without dot function to call to execute this pseudo-op - integer arg to pass to the function */ + integer arg to pass to the function */ extern void obj_coff_section (); const pseudo_typeS md_pseudo_table[] = { - { "align", s_align_bytes, 4 }, /* Do byte alignment, default is a 4 byte boundary */ - { "word", cons, 4 }, /* FIXME: Should this be machine independent? */ + { "align", s_align_bytes, 4 }, /* Do byte alignment, default is a 4 byte boundary */ + { "word", cons, 4 }, /* FIXME: Should this be machine independent? */ { "bss", s_lcomm_bytes, 1 }, - { "sect", obj_coff_section, 0}, /* For compatibility with TI tools */ - { "section", obj_coff_section, 0}, /* Standard COFF .section pseudo-op */ + { "sect", obj_coff_section, 0}, /* For compatibility with TI tools */ + { "section", obj_coff_section, 0}, /* Standard COFF .section pseudo-op */ { NULL, NULL, 0 } }; @@ -75,12 +76,12 @@ static void build_insn PARAMS ((struct tic80_opcode *, expressionS *)); static int get_operands PARAMS ((expressionS exp[])); static int const_overflow PARAMS ((unsigned long num, int bits, int flags)); -/* Replace short PC relative instructions with long form when necessary. Currently - this is off by default or when given the -no-relax option. Turning it on by using - the -relax option forces all PC relative instructions to use the long form, which - is why it is currently not the default. */ +/* Replace short PC relative instructions with long form when + necessary. Currently this is off by default or when given the + -no-relax option. Turning it on by using the -relax option forces + all PC relative instructions to use the long form, which is why it + is currently not the default. */ static int tic80_relax = 0; - int md_estimate_size_before_relax (fragP, segment_type) @@ -93,7 +94,6 @@ md_estimate_size_before_relax (fragP, segment_type) /* We have no need to default values of symbols. */ -/* ARGSUSED */ symbolS * md_undefined_symbol (name) char *name; @@ -101,10 +101,10 @@ md_undefined_symbol (name) return 0; } -/* Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ +/* Turn a string in input_line_pointer into a floating point constant + of type TYPE, and store the appropriate bytes in *LITP. The number + of LITTLENUMS emitted is stored in *SIZEP. An error message is + returned, or NULL on OK. */ #define MAX_LITTLENUMS 4 @@ -119,7 +119,7 @@ md_atof (type, litP, sizeP) LITTLENUM_TYPE *wordP; char *t; char *atof_ieee (); - + switch (type) { case 'f': @@ -146,9 +146,9 @@ md_atof (type, litP, sizeP) { input_line_pointer = t; } - + *sizeP = prec * sizeof (LITTLENUM_TYPE); - + for (wordP = words; prec--;) { md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE)); @@ -158,7 +158,7 @@ md_atof (type, litP, sizeP) } /* Check to see if the constant value in NUM will fit in a field of - width BITS if it has flags FLAGS. */ + width BITS if it has flags FLAGS. */ static int const_overflow (num, bits, flags) @@ -169,12 +169,12 @@ const_overflow (num, bits, flags) long min, max; int retval = 0; - /* Only need to check fields less than 32 bits wide */ + /* Only need to check fields less than 32 bits wide. */ if (bits < 32) if (flags & TIC80_OPERAND_SIGNED) { - max = (1 << (bits - 1)) - 1; - min = - (1 << (bits - 1)); + max = (1 << (bits - 1)) - 1; + min = - (1 << (bits - 1)); retval = ((long) num > max) || ((long) num < min); } else @@ -186,19 +186,17 @@ const_overflow (num, bits, flags) return (retval); } -/* get_operands() parses a string of operands and fills in a passed array of - expressions in EXP. +/* get_operands () parses a string of operands and fills in a passed + array of expressions in EXP. Note that we use O_absent expressions to record additional information about the previous non-O_absent expression, such as ":m" or ":s" modifiers or register numbers enclosed in parens like "(r10)". - Returns the number of expressions that were placed in EXP. - - */ + Returns the number of expressions that were placed in EXP. */ static int -get_operands (exp) +get_operands (exp) expressionS exp[]; { char *p = input_line_pointer; @@ -207,37 +205,33 @@ get_operands (exp) int sflag = 0; int parens = 0; - while (*p) + while (*p) { - /* Skip leading whitespace */ - while (*p == ' ' || *p == '\t' || *p == ',') - { - p++; - } + /* Skip leading whitespace. */ + while (*p == ' ' || *p == '\t' || *p == ',') + p++; + + /* Check to see if we have any operands left to parse. */ + if (*p == 0 || *p == '\n' || *p == '\r') + break; - /* Check to see if we have any operands left to parse */ - if (*p == 0 || *p == '\n' || *p == '\r') - { - break; - } - /* Notice scaling or direct memory operand modifiers and save them in - an O_absent expression after the expression that they modify. */ + an O_absent expression after the expression that they modify. */ - if (*p == ':') + if (*p == ':') { p++; exp[numexp].X_op = O_absent; - if (*p == 'm') + if (*p == 'm') { p++; - /* This is a ":m" modifier */ + /* This is a ":m" modifier. */ exp[numexp].X_add_number = TIC80_OPERAND_M_SI | TIC80_OPERAND_M_LI; } else if (*p == 's') { p++; - /* This is a ":s" modifier */ + /* This is a ":s" modifier. */ exp[numexp].X_add_number = TIC80_OPERAND_SCALED; } else @@ -250,34 +244,32 @@ get_operands (exp) /* Handle leading '(' on operands that use them, by recording that we have entered a paren nesting level and then continuing. We complain - about multiple nesting. */ + about multiple nesting. */ if (*p == '(') { if (++parens != 1) - { - as_bad (_("paren nesting")); - } + as_bad (_("paren nesting")); + p++; continue; } /* Handle trailing ')' on operands that use them, by reducing the nesting level and then continuing. We complain if there were too - many closures. */ + many closures. */ - if (*p == ')') + if (*p == ')') { - /* Record that we have left a paren group and continue */ + /* Record that we have left a paren group and continue. */ if (--parens < 0) - { - as_bad (_("mismatched parenthesis")); - } + as_bad (_("mismatched parenthesis")); + p++; continue; } - /* Begin operand parsing at the current scan point. */ + /* Begin operand parsing at the current scan point. */ input_line_pointer = p; expression (&exp[numexp]); @@ -301,7 +293,7 @@ get_operands (exp) exp[numexp++].X_add_number = TIC80_OPERAND_PARENS; } - /* Mark the end of the valid operands with an illegal expression. */ + /* Mark the end of the valid operands with an illegal expression. */ exp[numexp].X_op = O_illegal; return (numexp); @@ -332,19 +324,19 @@ find_opcode (opcode, myops) const struct tic80_opcode *end; /* Pointer to end of opcode table */ /* First parse all the operands so we only have to do it once. There may - be more expressions generated than there are operands. */ + be more expressions generated than there are operands. */ numexp = get_operands (myops); /* For each opcode with the same name, try to match it against the parsed - operands. */ + operands. */ end = tic80_opcodes + tic80_num_opcodes; - while (!match && (opc < end) && (strcmp (opc -> name, opcode -> name) == 0)) + while (!match && (opc < end) && (strcmp (opc->name, opcode->name) == 0)) { /* Start off assuming a match. If we find a mismatch, then this is reset and the operand/expr matching loop terminates with match - equal to zero, which allows us to try the next opcode. */ + equal to zero, which allows us to try the next opcode. */ match = 1; @@ -362,21 +354,21 @@ find_opcode (opcode, myops) /* The O_absent expressions apply to the same operand as the most recent non O_absent expression. So only increment the operand index when the current expression is not one of these special - expressions. */ + expressions. */ if (X_op != O_absent) { opi++; } - flags = tic80_operands[opc -> operands[opi]].flags; - bits = tic80_operands[opc -> operands[opi]].bits; + flags = tic80_operands[opc->operands[opi]].flags; + bits = tic80_operands[opc->operands[opi]].bits; switch (X_op) { case O_register: - /* Also check that registers that are supposed to be even actually - are even. */ + /* Also check that registers that are supposed to be + even actually are even. */ if (((flags & TIC80_OPERAND_GPR) != (num & TIC80_OPERAND_GPR)) || ((flags & TIC80_OPERAND_FPA) != (num & TIC80_OPERAND_FPA)) || ((flags & TIC80_OPERAND_CR) != (num & TIC80_OPERAND_CR)) || @@ -389,7 +381,8 @@ find_opcode (opcode, myops) case O_constant: if ((flags & TIC80_OPERAND_ENDMASK) && (num == 32)) { - /* Endmask values of 0 and 32 give identical results */ + /* Endmask values of 0 and 32 give identical + results. */ num = 0; } if ((flags & (TIC80_OPERAND_FPA | TIC80_OPERAND_GPR)) || @@ -399,35 +392,43 @@ find_opcode (opcode, myops) } break; case O_symbol: - if ((bits < 32) && (flags & TIC80_OPERAND_PCREL) && !tic80_relax) + if ((bits < 32) && (flags & TIC80_OPERAND_PCREL) + && !tic80_relax) { - /* The default is to prefer the short form of PC relative relocations. - This is the only form that the TI assembler supports. - If the -relax option is given, we never use the short forms. - FIXME: Should be able to choose "best-fit". */ + /* The default is to prefer the short form of PC + relative relocations. This is the only form that + the TI assembler supports. If the -relax option + is given, we never use the short forms. + FIXME: Should be able to choose "best-fit". */ } - else if ((bits == 32) /* && (flags & TIC80_OPERAND_BASEREL) */) + else if ((bits == 32) +#if 0 + && (flags & TIC80_OPERAND_BASEREL) +#endif + ) { - /* The default is to prefer the long form of base relative relocations. - This is the only form that the TI assembler supports. - If the -no-relax option is given, we always use the long form of + /* The default is to prefer the long form of base + relative relocations. This is the only form that + the TI assembler supports. If the -no-relax + option is given, we always use the long form of PC relative relocations. - FIXME: Should be able to choose "best-fit". */ + FIXME: Should be able to choose "best-fit". */ } else { /* Symbols that don't match one of the above cases are - rejected as an operand. */ + rejected as an operand. */ match = 0; } break; case O_absent: - /* If this is an O_absent expression, then it may be an expression that - supplies additional information about the operand, such as ":m" or - ":s" modifiers. Check to see that the operand matches this requirement. */ - if (!((num & TIC80_OPERAND_M_SI) && (flags & TIC80_OPERAND_M_SI) || - (num & TIC80_OPERAND_M_LI) && (flags & TIC80_OPERAND_M_LI) || - (num & TIC80_OPERAND_SCALED) && (flags & TIC80_OPERAND_SCALED))) + /* If this is an O_absent expression, then it may be an + expression that supplies additional information about + the operand, such as ":m" or ":s" modifiers. Check to + see that the operand matches this requirement. */ + if (!((num & TIC80_OPERAND_M_SI) && (flags & TIC80_OPERAND_M_SI) + || (num & TIC80_OPERAND_M_LI) && (flags & TIC80_OPERAND_M_LI) + || (num & TIC80_OPERAND_SCALED) && (flags & TIC80_OPERAND_SCALED))) { match = 0; } @@ -468,96 +469,94 @@ find_opcode (opcode, myops) } } if (!match) - { - opc++; - } - } + opc++; + } return (match ? opc : NULL); #if 0 - /* Now search the opcode table table for one with operands that - matches what we've got. */ + matches what we've got. */ while (!match) { match = 1; - for (i = 0; opcode -> operands[i]; i++) + for (i = 0; opcode->operands[i]; i++) { int flags = tic80_operands[opcode->operands[i]].flags; int X_op = myops[i].X_op; int num = myops[i].X_add_number; - if (X_op == 0) + if (X_op == 0) { match = 0; break; } - - if (flags & (TIC80_OPERAND_GPR | TIC80_OPERAND_FPA | TIC80_OPERAND_CR)) + + if (flags + & (TIC80_OPERAND_GPR | TIC80_OPERAND_FPA | TIC80_OPERAND_CR)) { if ((X_op != O_register) || ((flags & TIC80_OPERAND_GPR) != (num & TIC80_OPERAND_GPR)) || ((flags & TIC80_OPERAND_FPA) != (num & TIC80_OPERAND_FPA)) || ((flags & TIC80_OPERAND_CR) != (num & TIC80_OPERAND_CR))) { - match=0; + match = 0; break; - } + } } - + if (((flags & TIC80_OPERAND_MINUS) && ((X_op != O_absent) || (num != TIC80_OPERAND_MINUS))) || ((flags & TIC80_OPERAND_PLUS) && ((X_op != O_absent) || (num != TIC80_OPERAND_PLUS))) || ((flags & TIC80_OPERAND_ATMINUS) && ((X_op != O_absent) || (num != TIC80_OPERAND_ATMINUS))) || ((flags & TIC80_OPERAND_ATPAR) && ((X_op != O_absent) || (num != TIC80_OPERAND_ATPAR))) || - ((flags & TIC80_OPERAND_ATSIGN) && ((X_op != O_absent) || (num != TIC80_OPERAND_ATSIGN)))) + ((flags & TIC80_OPERAND_ATSIGN) && ((X_op != O_absent) || (num != TIC80_OPERAND_ATSIGN)))) { - match=0; + match = 0; break; - } + } } - /* we're only done if the operands matched so far AND there - are no more to check */ - if (match && myops[i].X_op==0) + /* We're only done if the operands matched so far AND there + are no more to check. */ + if (match && myops[i].X_op == 0) break; else match = 0; - next_opcode = opcode+1; - if (next_opcode->opcode == 0) + next_opcode = opcode + 1; + if (next_opcode->opcode == 0) break; - if (strcmp(next_opcode->name, opcode->name)) + if (strcmp (next_opcode->name, opcode->name)) break; opcode = next_opcode; } - if (!match) + if (!match) { as_bad (_("bad opcode or operands")); return (0); } - /* Check that all registers that are required to be even are. */ - /* Also, if any operands were marked as registers, but were really symbols */ - /* fix that here. */ - for (i=0; opcode->operands[i]; i++) + /* Check that all registers that are required to be even are. + Also, if any operands were marked as registers, but were really + symbols, fix that here. */ + for (i = 0; opcode->operands[i]; i++) { - if ((tic80_operands[opcode->operands[i]].flags & TIC80_OPERAND_EVEN) && - (myops[i].X_add_number & 1)) + if ((tic80_operands[opcode->operands[i]].flags & TIC80_OPERAND_EVEN) + && (myops[i].X_add_number & 1)) as_fatal (_("Register number must be EVEN")); if (myops[i].X_op == O_register) { - if (!(tic80_operands[opcode->operands[i]].flags & TIC80_OPERAND_REG)) + if (!(tic80_operands[opcode->operands[i]].flags & TIC80_OPERAND_REG)) { myops[i].X_op = O_symbol; - myops[i].X_add_symbol = symbol_find_or_make ((char *)myops[i].X_op_symbol); + myops[i].X_add_symbol = + symbol_find_or_make ((char *) myops[i].X_op_symbol); myops[i].X_add_number = 0; myops[i].X_op_symbol = NULL; } } } - #endif } @@ -566,10 +565,10 @@ find_opcode (opcode, myops) Note that the opcode word and extended word may be written to different frags, with the opcode at the end of one frag and the extension at the - beginning of the next. */ + beginning of the next. */ static void -build_insn (opcode, opers) +build_insn (opcode, opers) struct tic80_opcode *opcode; expressionS *opers; { @@ -581,17 +580,17 @@ build_insn (opcode, opers) char *fx = NULL; /* Pointer to frag location for insn[1] */ fragS *fxfrag; /* Frag containing location fx */ - /* Start with the raw opcode bits from the opcode table. */ - insn[0] = opcode -> opcode; + /* Start with the raw opcode bits from the opcode table. */ + insn[0] = opcode->opcode; /* We are going to insert at least one 32 bit opcode so get the - frag now. */ + frag now. */ f = frag_more (4); ffrag = frag_now; /* For each operand expression, insert the appropriate bits into the - instruction . */ + instruction. */ for (expi = 0, opi = -1; opers[expi].X_op != O_illegal; expi++) { int bits, shift, flags, X_op, num; @@ -602,16 +601,16 @@ build_insn (opcode, opers) /* The O_absent expressions apply to the same operand as the most recent non O_absent expression. So only increment the operand index when the current expression is not one of these special - expressions. */ + expressions. */ if (X_op != O_absent) { opi++; } - flags = tic80_operands[opcode -> operands[opi]].flags; - bits = tic80_operands[opcode -> operands[opi]].bits; - shift = tic80_operands[opcode -> operands[opi]].shift; + flags = tic80_operands[opcode->operands[opi]].flags; + bits = tic80_operands[opcode->operands[opi]].bits; + shift = tic80_operands[opcode->operands[opi]].shift; switch (X_op) { @@ -622,15 +621,16 @@ build_insn (opcode, opers) case O_constant: if ((flags & TIC80_OPERAND_ENDMASK) && (num == 32)) { - /* Endmask values of 0 and 32 give identical results */ + /* Endmask values of 0 and 32 give identical results. */ num = 0; } else if ((flags & TIC80_OPERAND_BITNUM)) { - /* BITNUM values are stored in one's complement form */ + /* BITNUM values are stored in one's complement form. */ num = (~num & 0x1F); } - /* Mask off upper bits, just it case it is signed and is negative */ + /* Mask off upper bits, just it case it is signed and is + negative. */ if (bits < 32) { num &= (1 << bits) - 1; @@ -652,18 +652,18 @@ build_insn (opcode, opers) if (flags & TIC80_OPERAND_PCREL) { fix_new_exp (fxfrag, - fx - (fxfrag -> fr_literal), + fx - (fxfrag->fr_literal), 4, - &opers[expi], + &opers[expi], 1, R_MPPCR); } else { fix_new_exp (fxfrag, - fx - (fxfrag -> fr_literal), + fx - (fxfrag->fr_literal), 4, - &opers[expi], + &opers[expi], 0, R_RELLONGX); } @@ -671,8 +671,8 @@ build_insn (opcode, opers) else if (flags & TIC80_OPERAND_PCREL) { fix_new_exp (ffrag, - f - (ffrag -> fr_literal), - 4, /* FIXME! how is this used? */ + f - (ffrag->fr_literal), + 4, /* FIXME! how is this used? */ &opers[expi], 1, R_MPPCR15W); @@ -683,26 +683,33 @@ build_insn (opcode, opers) } break; case O_absent: - /* Each O_absent expression can indicate exactly one possible modifier. */ - if ((num & TIC80_OPERAND_M_SI) && (flags & TIC80_OPERAND_M_SI)) + /* Each O_absent expression can indicate exactly one + possible modifier. */ + if ((num & TIC80_OPERAND_M_SI) + && (flags & TIC80_OPERAND_M_SI)) { insn[0] = insn[0] | (1 << 17); } - else if ((num & TIC80_OPERAND_M_LI) && (flags & TIC80_OPERAND_M_LI)) + else if ((num & TIC80_OPERAND_M_LI) + && (flags & TIC80_OPERAND_M_LI)) { insn[0] = insn[0] | (1 << 15); } - else if ((num & TIC80_OPERAND_SCALED) && (flags & TIC80_OPERAND_SCALED)) + else if ((num & TIC80_OPERAND_SCALED) + && (flags & TIC80_OPERAND_SCALED)) { insn[0] = insn[0] | (1 << 11); } - else if ((num & TIC80_OPERAND_PARENS) && (flags & TIC80_OPERAND_PARENS)) + else if ((num & TIC80_OPERAND_PARENS) + && (flags & TIC80_OPERAND_PARENS)) { - /* No code to generate, just accept and discard this expression */ + /* No code to generate, just accept and discard this + expression. */ } else { - internal_error_a (_("unhandled operand modifier"), opers[expi].X_add_number); + internal_error_a (_("unhandled operand modifier"), + opers[expi].X_add_number); } break; case O_big: @@ -712,7 +719,7 @@ build_insn (opcode, opers) int precision = 2; long exponent_bits = 8L; LITTLENUM_TYPE words[2]; - /* Value is still in generic_floating_point_number */ + /* Value is still in generic_floating_point_number. */ gen_to_words (words, precision, exponent_bits); insn[1] = (words[0] << 16) | words[1]; } @@ -774,24 +781,22 @@ md_assemble (str) expressionS myops[16]; unsigned long insn; - /* Ensure there is something there to assemble. */ + /* Ensure there is something there to assemble. */ assert (str); - /* Drop any leading whitespace. */ + /* Drop any leading whitespace. */ while (isspace (*str)) - { - str++; - } + str++; /* Isolate the mnemonic from the rest of the string by finding the first whitespace character and zapping it to a null byte. */ - for (scan = str; *scan != '\000' && !isspace (*scan); scan++) {;} + for (scan = str; *scan != '\000' && !isspace (*scan); scan++) + ; + if (*scan != '\000') - { - *scan++ = '\000'; - } + *scan++ = '\000'; - /* Try to find this mnemonic in the hash table */ + /* Try to find this mnemonic in the hash table. */ if ((opcode = (struct tic80_opcode *) hash_find (tic80_hash, str)) == NULL) { as_bad (_("Invalid mnemonic: '%s'"), str); @@ -800,18 +805,14 @@ md_assemble (str) str = scan; while (isspace (*scan)) - { - scan++; - } + scan++; input_line_save = input_line_pointer; input_line_pointer = str; opcode = find_opcode (opcode, myops); if (opcode == NULL) - { - as_bad (_("Invalid operands: '%s'"), input_line_save); - } + as_bad (_("Invalid operands: '%s'"), input_line_save); input_line_pointer = input_line_save; build_insn (opcode, myops); @@ -831,12 +832,12 @@ md_begin () register const struct tic80_opcode *op; register const struct tic80_opcode *op_end; const struct predefined_symbol *pdsp; - extern int coff_flags; /* Defined in obj-coff.c */ + extern int coff_flags; /* Defined in obj-coff.c */ /* Set F_AR32WR in coff_flags, which will end up in the file header - f_flags field. */ + f_flags field. */ - coff_flags |= F_AR32WR; /* TIc80 is 32 bit little endian */ + coff_flags |= F_AR32WR; /* TIc80 is 32 bit little endian. */ /* Insert unique names into hash table. The TIc80 instruction set has many identical opcode names that have different opcodes based @@ -847,23 +848,25 @@ md_begin () op_end = tic80_opcodes + tic80_num_opcodes; for (op = tic80_opcodes; op < op_end; op++) { - if (strcmp (prev_name, op -> name) != 0) + if (strcmp (prev_name, op->name) != 0) { - prev_name = (char *) op -> name; - hash_insert (tic80_hash, op -> name, (char *) op); + prev_name = (char *) op->name; + hash_insert (tic80_hash, op->name, (char *) op); } } - /* Insert the predefined symbols into the symbol table. We use symbol_create - rather than symbol_new so that these symbols don't end up in the object - files' symbol table. Note that the values of the predefined symbols include - some upper bits that distinguish the type of the symbol (register, bitnum, - condition code, etc) and these bits must be masked away before actually - inserting the values into the instruction stream. For registers we put - these bits in the symbol table since we use them later and there is no - question that they aren't part of the register number. For constants we - can't do that since the constant can be any value, so they are masked off - before putting them into the symbol table. */ + /* Insert the predefined symbols into the symbol table. We use + symbol_create rather than symbol_new so that these symbols don't + end up in the object files' symbol table. Note that the values + of the predefined symbols include some upper bits that + distinguish the type of the symbol (register, bitnum, condition + code, etc) and these bits must be masked away before actually + inserting the values into the instruction stream. For registers + we put these bits in the symbol table since we use them later and + there is no question that they aren't part of the register + number. For constants we can't do that since the constant can be + any value, so they are masked off before putting them into the + symbol table. */ pdsp = NULL; while ((pdsp = tic80_next_predefined_symbol (pdsp)) != NULL) @@ -894,15 +897,13 @@ md_begin () &zero_address_frag)); } } - - -/* The assembler adds md_shortopts to the string passed to getopt. */ +/* The assembler adds md_shortopts to the string passed to getopt. */ CONST char *md_shortopts = ""; /* The assembler adds md_longopts to the machine independent long options - that are passed to getopt. */ + that are passed to getopt. */ struct option md_longopts[] = { @@ -915,11 +916,11 @@ struct option md_longopts[] = { {NULL, no_argument, NULL, 0} }; -size_t md_longopts_size = sizeof(md_longopts); +size_t md_longopts_size = sizeof (md_longopts); /* The md_parse_option function will be called whenever getopt returns an unrecognized code, presumably indicating a special code value which - appears in md_longopts for machine specific command line options. */ + appears in md_longopts for machine specific command line options. */ int md_parse_option (c, arg) @@ -942,7 +943,7 @@ md_parse_option (c, arg) /* The md_show_usage function will be called whenever a usage message is printed. It should print a description of the machine specific options - found in md_longopts. */ + found in md_longopts. */ void md_show_usage (stream) @@ -953,22 +954,20 @@ TIc80 options:\n\ -relax alter PC relative branch instructions to use long form when needed\n\ -no-relax always use short PC relative branch instructions, error on overflow\n"); } - /* Attempt to simplify or even eliminate a fixup. The return value is ignored; perhaps it was once meaningful, but now it is historical. - To indicate that a fixup has been eliminated, set fixP->fx_done. - */ + To indicate that a fixup has been eliminated, set fixP->fx_done. */ void md_apply_fix (fixP, val) fixS *fixP; long val; { - char *dest = fixP -> fx_frag -> fr_literal + fixP -> fx_where; + char *dest = fixP->fx_frag->fr_literal + fixP->fx_where; int overflow; - switch (fixP -> fx_r_type) + switch (fixP->fx_r_type) { case R_RELLONGX: md_number_to_chars (dest, (valueT) val, 4); @@ -982,7 +981,7 @@ md_apply_fix (fixP, val) overflow = (val < -65536L) || (val > 65532L); if (overflow) { - as_bad_where (fixP -> fx_file, fixP -> fx_line, + as_bad_where (fixP->fx_file, fixP->fx_line, _("PC offset 0x%lx outside range 0x%lx-0x%lx"), val, -65536L, 65532L); } @@ -995,14 +994,14 @@ md_apply_fix (fixP, val) } break; case R_ABS: - md_number_to_chars (dest, (valueT) val, fixP -> fx_size); + md_number_to_chars (dest, (valueT) val, fixP->fx_size); break; default: - internal_error_a (_("unhandled relocation type in fixup"), fixP -> fx_r_type); + internal_error_a (_("unhandled relocation type in fixup"), + fixP->fx_r_type); break; } } - /* Functions concerning relocs. */ @@ -1010,17 +1009,16 @@ md_apply_fix (fixP, val) given a PC relative reloc. For the TIc80, this is the address of the 32 bit opcode containing - the PC relative field. */ + the PC relative field. */ long md_pcrel_from (fixP) fixS *fixP; { - return (fixP -> fx_frag -> fr_address + fixP -> fx_where) ; + return (fixP->fx_frag->fr_address + fixP->fx_where); } -/* - * Called after relax() is finished. +/* Called after relax() is finished. * In: Address of frag. * fr_type == rs_machine_dependent. * fr_subtype is what the address relaxed to. @@ -1038,9 +1036,7 @@ md_convert_frag (headers, seg, fragP) internal_error (_("md_convert_frag() not implemented yet")); abort (); } - -/*ARGSUSED*/ void tc_coff_symbol_emit_hook (ignore) symbolS *ignore; @@ -1053,9 +1049,7 @@ short tc_coff_fix2rtype (fixP) fixS *fixP; { - return (fixP -> fx_r_type); + return (fixP->fx_r_type); } -#endif /* OBJ_COFF */ - -/* end of tc-tic80.c */ +#endif /* OBJ_COFF */ |