1 /* tc-c4x.c -- Assemble for the Texas Instruments TMS320C[34]x.
2 Copyright (C) 1997,1998, 2002 Free Software Foundation.
4 Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
26 o .align cannot handle fill-data larger than 0xFF/8-bits
28 o .align fills all section with NOP's when used regardless if has
29 been used in .text or .data. (However the .align is primarely
30 intended used in .text sections. If you require something else,
31 use .align <size>,0x00)
33 o .align: Implement a 'bu' insn if the number of nop's exeeds 4 within
34 the align frag. if(fragsize>4words) insert bu fragend+1 first.
36 o .usect if has symbol on previous line not implemented
38 o .sym, .eos, .stag, .etag, .member not implemented
40 o Evaluation of constant floating point expressions (expr.c needs work!)
42 o Warnings issued if parallel load of same register
44 o Support 'abc' constants?
46 o Support new opcodes and implement a silicon version switch (maybe -mpg)
48 o Disallow non-float registers in float instructions. Make as require
49 'fx' notation on floats, while 'rx' on the rest
56 #include "opcode/tic4x.h"
62 /* OK, we accept a syntax similar to the other well known C30
63 assembly tools. With C4X_ALT_SYNTAX defined we are more
64 flexible, allowing a more Unix-like syntax: `%' in front of
65 register names, `#' in front of immediate constants, and
66 not requiring `@' in front of direct addresses. */
68 #define C4X_ALT_SYNTAX
70 /* Equal to MAX_PRECISION in atof-ieee.c. */
71 #define MAX_LITTLENUMS 6 /* (12 bytes) */
73 /* Handle of the inst mnemonic hash table. */
74 static struct hash_control *c4x_op_hash = NULL;
76 /* Handle asg pseudo. */
77 static struct hash_control *c4x_asg_hash = NULL;
79 static unsigned int c4x_cpu = 0; /* Default to TMS320C40. */
80 static unsigned int c4x_big_model = 0; /* Default to small memory model. */
81 static unsigned int c4x_reg_args = 0; /* Default to args passed on stack. */
85 M_UNKNOWN, M_IMMED, M_DIRECT, M_REGISTER, M_INDIRECT,
86 M_IMMED_F, M_PARALLEL, M_HI
90 typedef struct c4x_operand
92 c4x_addr_mode_t mode; /* Addressing mode. */
93 expressionS expr; /* Expression. */
94 int disp; /* Displacement for indirect addressing. */
95 int aregno; /* Aux. register number. */
96 LITTLENUM_TYPE fwords[MAX_LITTLENUMS]; /* Float immed. number. */
100 typedef struct c4x_insn
102 char name[C4X_NAME_MAX]; /* Mnemonic of instruction. */
103 unsigned int in_use; /* True if in_use. */
104 unsigned int parallel; /* True if parallel instruction. */
105 unsigned int nchars; /* This is always 4 for the C30. */
106 unsigned long opcode; /* Opcode number. */
107 expressionS exp; /* Expression required for relocation. */
108 int reloc; /* Relocation type required. */
109 int pcrel; /* True if relocation PC relative. */
110 char *pname; /* Name of instruction in parallel. */
111 unsigned int num_operands; /* Number of operands in total. */
112 c4x_inst_t *inst; /* Pointer to first template. */
113 c4x_operand_t operands[C4X_OPERANDS_MAX];
117 static c4x_insn_t the_insn; /* Info about our instruction. */
118 static c4x_insn_t *insn = &the_insn;
120 static int c4x_gen_to_words
121 PARAMS ((FLONUM_TYPE, LITTLENUM_TYPE *, int ));
122 static char *c4x_atof
123 PARAMS ((char *, char, LITTLENUM_TYPE * ));
124 static void c4x_insert_reg
125 PARAMS ((char *, int ));
126 static void c4x_insert_sym
127 PARAMS ((char *, int ));
128 static char *c4x_expression
129 PARAMS ((char *, expressionS *));
130 static char *c4x_expression_abs
131 PARAMS ((char *, int *));
132 static void c4x_emit_char
133 PARAMS ((char, int));
134 static void c4x_seg_alloc
135 PARAMS ((char *, segT, int, symbolS *));
140 static void c4x_globl
144 static void c4x_stringer
148 static void c4x_newblock
154 static void c4x_usect
156 static void c4x_version
158 static void c4x_pseudo_ignore
160 static void c4x_init_regtable
162 static void c4x_init_symbols
164 static int c4x_inst_insert
165 PARAMS ((c4x_inst_t *));
166 static c4x_inst_t *c4x_inst_make
167 PARAMS ((char *, unsigned long, char *));
168 static int c4x_inst_add
169 PARAMS ((c4x_inst_t *));
174 static int c4x_indirect_parse
175 PARAMS ((c4x_operand_t *, const c4x_indirect_t *));
176 static char *c4x_operand_parse
177 PARAMS ((char *, c4x_operand_t *));
178 static int c4x_operands_match
179 PARAMS ((c4x_inst_t *, c4x_insn_t *));
180 static void c4x_insn_output
181 PARAMS ((c4x_insn_t *));
182 static int c4x_operands_parse
183 PARAMS ((char *, c4x_operand_t *, int ));
189 PARAMS ((int, char *, int *));
191 PARAMS ((fixS *, valueT *, segT ));
193 PARAMS ((bfd *, segT, fragS *));
194 void md_create_short_jump
195 PARAMS ((char *, addressT, addressT, fragS *, symbolS *));
196 void md_create_long_jump
197 PARAMS ((char *, addressT, addressT, fragS *, symbolS *));
198 int md_estimate_size_before_relax
199 PARAMS ((register fragS *, segT));
201 PARAMS ((int, char *));
204 int c4x_unrecognized_line
206 symbolS *md_undefined_symbol
209 PARAMS ((expressionS *));
210 valueT md_section_align
211 PARAMS ((segT, valueT));
212 static int c4x_pc_offset
213 PARAMS ((unsigned int));
217 PARAMS ((int, const char *, int, int));
220 arelent *tc_gen_reloc
221 PARAMS ((asection *, fixS *));
227 {"align", s_align_bytes, 32},
228 {"ascii", c4x_stringer, 1},
229 {"asciz", c4x_stringer, 0},
231 {"block", s_space, 4},
232 {"byte", c4x_cons, 1},
234 {"copy", s_include, 0},
235 {"def", c4x_globl, 0},
237 {"eval", c4x_eval, 0},
238 {"global", c4x_globl, 0},
239 {"globl", c4x_globl, 0},
240 {"hword", c4x_cons, 2},
241 {"ieee", float_cons, 'i'},
242 {"int", c4x_cons, 4}, /* .int allocates 4 bytes. */
243 {"ldouble", float_cons, 'e'},
244 {"newblock", c4x_newblock, 0},
245 {"ref", s_ignore, 0}, /* All undefined treated as external. */
247 {"sect", c4x_sect, 1}, /* Define named section. */
248 {"space", s_space, 4},
249 {"string", c4x_stringer, 0},
250 {"usect", c4x_usect, 0}, /* Reserve space in uninit. named sect. */
251 {"version", c4x_version, 0},
252 {"word", c4x_cons, 4}, /* .word allocates 4 bytes. */
253 {"xdef", c4x_globl, 0},
257 int md_short_jump_size = 4;
258 int md_long_jump_size = 4;
259 const int md_reloc_size = RELSZ; /* Coff headers. */
261 /* This array holds the chars that always start a comment. If the
262 pre-processor is disabled, these aren't very useful. */
263 #ifdef C4X_ALT_SYNTAX
264 const char comment_chars[] = ";!";
266 const char comment_chars[] = ";";
269 /* This array holds the chars that only start a comment at the beginning of
270 a line. If the line seems to have the form '# 123 filename'
271 .line and .file directives will appear in the pre-processed output.
272 Note that input_file.c hand checks for '#' at the beginning of the
273 first line of the input file. This is because the compiler outputs
274 #NO_APP at the beginning of its output.
275 Also note that comments like this one will always work. */
276 const char line_comment_chars[] = "#*";
278 /* We needed an unused char for line separation to work around the
279 lack of macros, using sed and such. */
280 const char line_separator_chars[] = "&";
282 /* Chars that can be used to separate mant from exp in floating point nums. */
283 const char EXP_CHARS[] = "eE";
285 /* Chars that mean this number is a floating point constant. */
288 const char FLT_CHARS[] = "fFilsS";
290 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
291 changed in read.c. Ideally it shouldn't have to know about it at
292 all, but nothing is ideal around here. */
294 /* Flonums returned here. */
295 extern FLONUM_TYPE generic_floating_point_number;
297 /* Precision in LittleNums. */
298 #define MAX_PRECISION (4) /* Its a bit overkill for us, but the code
300 #define S_PRECISION (1) /* Short float constants 16-bit. */
301 #define F_PRECISION (2) /* Float and double types 32-bit. */
302 #define E_PRECISION (4) /* Extended precision, 64-bit (real 40-bit). */
305 /* Turn generic_floating_point_number into a real short/float/double. */
307 c4x_gen_to_words (flonum, words, precision)
309 LITTLENUM_TYPE *words;
312 int return_value = 0;
313 LITTLENUM_TYPE *p; /* Littlenum pointer. */
314 int mantissa_bits; /* Bits in mantissa field. */
315 int exponent_bits; /* Bits in exponent field. */
317 unsigned int sone; /* Scaled one. */
318 unsigned int sfract; /* Scaled fraction. */
319 unsigned int smant; /* Scaled mantissa. */
321 unsigned int mover; /* Mantissa overflow bits */
322 unsigned int rbit; /* Round bit. */
323 int shift; /* Shift count. */
325 /* NOTE: Svein Seldal <Svein.Seldal@solidas.com>
326 The code in this function is altered slightly to support floats
327 with 31-bits mantissas, thus the documentation below may be a
328 little bit inaccurate.
330 By Michael P. Hayes <m.hayes@elec.canterbury.ac.nz>
331 Here is how a generic floating point number is stored using
332 flonums (an extension of bignums) where p is a pointer to an
335 For example 2e-3 is stored with exp = -4 and
342 with low = &bits[2], high = &bits[5], and leader = &bits[5].
344 This number can be written as
345 0x0083126e978d4fde.00000000 * 65536**-4 or
346 0x0.0083126e978d4fde * 65536**0 or
347 0x0.83126e978d4fde * 2**-8 = 2e-3
349 Note that low points to the 65536**0 littlenum (bits[2]) and
350 leader points to the most significant non-zero littlenum
353 TMS320C3X floating point numbers are a bit of a strange beast.
354 The 32-bit flavour has the 8 MSBs representing the exponent in
355 twos complement format (-128 to +127). There is then a sign bit
356 followed by 23 bits of mantissa. The mantissa is expressed in
357 twos complement format with the binary point after the most
358 significant non sign bit. The bit after the binary point is
359 suppressed since it is the complement of the sign bit. The
360 effective mantissa is thus 24 bits. Zero is represented by an
363 The 16-bit flavour has the 4 MSBs representing the exponent in
364 twos complement format (-8 to +7). There is then a sign bit
365 followed by 11 bits of mantissa. The mantissa is expressed in
366 twos complement format with the binary point after the most
367 significant non sign bit. The bit after the binary point is
368 suppressed since it is the complement of the sign bit. The
369 effective mantissa is thus 12 bits. Zero is represented by an
370 exponent of -8. For example,
372 number norm mant m x e s i fraction f
373 +0.500 => 1.00000000000 -1 -1 0 1 .00000000000 (1 + 0) * 2^(-1)
374 +0.999 => 1.11111111111 -1 -1 0 1 .11111111111 (1 + 0.99) * 2^(-1)
375 +1.000 => 1.00000000000 0 0 0 1 .00000000000 (1 + 0) * 2^(0)
376 +1.500 => 1.10000000000 0 0 0 1 .10000000000 (1 + 0.5) * 2^(0)
377 +1.999 => 1.11111111111 0 0 0 1 .11111111111 (1 + 0.9) * 2^(0)
378 +2.000 => 1.00000000000 1 1 0 1 .00000000000 (1 + 0) * 2^(1)
379 +4.000 => 1.00000000000 2 2 0 1 .00000000000 (1 + 0) * 2^(2)
380 -0.500 => 1.00000000000 -1 -1 1 0 .10000000000 (-2 + 0) * 2^(-2)
381 -1.000 => 1.00000000000 0 -1 1 0 .00000000000 (-2 + 0) * 2^(-1)
382 -1.500 => 1.10000000000 0 0 1 0 .10000000000 (-2 + 0.5) * 2^(0)
383 -1.999 => 1.11111111111 0 0 1 0 .00000000001 (-2 + 0.11) * 2^(0)
384 -2.000 => 1.00000000000 1 1 1 0 .00000000000 (-2 + 0) * 2^(0)
385 -4.000 => 1.00000000000 2 1 1 0 .00000000000 (-2 + 0) * 2^(1)
387 where e is the exponent, s is the sign bit, i is the implied bit,
388 and f is the fraction stored in the mantissa field.
390 num = (1 + f) * 2^x = m * 2^e if s = 0
391 num = (-2 + f) * 2^x = -m * 2^e if s = 1
392 where 0 <= f < 1.0 and 1.0 <= m < 2.0
394 The fraction (f) and exponent (e) fields for the TMS320C3X format
395 can be derived from the normalised mantissa (m) and exponent (x) using:
397 f = m - 1, e = x if s = 0
398 f = 2 - m, e = x if s = 1 and m != 1.0
399 f = 0, e = x - 1 if s = 1 and m = 1.0
400 f = 0, e = -8 if m = 0
403 OK, the other issue we have to consider is rounding since the
404 mantissa has a much higher potential precision than what we can
405 represent. To do this we add half the smallest storable fraction.
406 We then have to renormalise the number to allow for overflow.
408 To convert a generic flonum into a TMS320C3X floating point
409 number, here's what we try to do....
411 The first thing is to generate a normalised mantissa (m) where
412 1.0 <= m < 2 and to convert the exponent from base 16 to base 2.
413 We desire the binary point to be placed after the most significant
414 non zero bit. This process is done in two steps: firstly, the
415 littlenum with the most significant non zero bit is located (this
416 is done for us since leader points to this littlenum) and the
417 binary point (which is currently after the LSB of the littlenum
418 pointed to by low) is moved to before the MSB of the littlenum
419 pointed to by leader. This requires the exponent to be adjusted
420 by leader - low + 1. In the earlier example, the new exponent is
421 thus -4 + (5 - 2 + 1) = 0 (base 65536). We now need to convert
422 the exponent to base 2 by multiplying the exponent by 16 (log2
423 65536). The exponent base 2 is thus also zero.
425 The second step is to hunt for the most significant non zero bit
426 in the leader littlenum. We do this by left shifting a copy of
427 the leader littlenum until bit 16 is set (0x10000) and counting
428 the number of shifts, S, required. The number of shifts then has to
429 be added to correct the exponent (base 2). For our example, this
430 will require 9 shifts and thus our normalised exponent (base 2) is
431 0 + 9 = 9. Note that the worst case scenario is when the leader
432 littlenum is 1, thus requiring 16 shifts.
434 We now have to left shift the other littlenums by the same amount,
435 propagating the shifted bits into the more significant littlenums.
436 To save a lot of unecessary shifting we only have to consider
437 two or three littlenums, since the greatest number of mantissa
438 bits required is 24 + 1 rounding bit. While two littlenums
439 provide 32 bits of precision, the most significant littlenum
440 may only contain a single significant bit and thus an extra
441 littlenum is required.
443 Denoting the number of bits in the fraction field as F, we require
444 G = F + 2 bits (one extra bit is for rounding, the other gets
445 suppressed). Say we required S shifts to find the most
446 significant bit in the leader littlenum, the number of left shifts
447 required to move this bit into bit position G - 1 is L = G + S - 17.
448 Note that this shift count may be negative for the short floating
449 point flavour (where F = 11 and thus G = 13 and potentially S < 3).
450 If L > 0 we have to shunt the next littlenum into position. Bit
451 15 (the MSB) of the next littlenum needs to get moved into position
452 L - 1 (If L > 15 we need all the bits of this littlenum and
453 some more from the next one.). We subtract 16 from L and use this
454 as the left shift count; the resultant value we or with the
455 previous result. If L > 0, we repeat this operation. */
457 if (precision != S_PRECISION)
459 if (precision == E_PRECISION)
460 words[2] = words[3] = 0x0000;
462 /* 0.0e0 or NaN seen. */
463 if (flonum.low > flonum.leader /* = 0.0e0 */
464 || flonum.sign == 0) /* = NaN */
467 as_bad ("Nan, using zero.");
472 if (flonum.sign == 'P')
474 /* +INF: Replace with maximum float. */
475 if (precision == S_PRECISION)
482 if (precision == E_PRECISION)
489 else if (flonum.sign == 'N')
491 /* -INF: Replace with maximum float. */
492 if (precision == S_PRECISION)
496 if (precision == E_PRECISION)
501 exponent = (flonum.exponent + flonum.leader - flonum.low + 1) * 16;
503 if (!(tmp = *flonum.leader))
504 abort (); /* Hmmm. */
505 shift = 0; /* Find position of first sig. bit. */
508 exponent -= (16 - shift); /* Adjust exponent. */
510 if (precision == S_PRECISION) /* Allow 1 rounding bit. */
515 else if(precision == F_PRECISION)
520 else /* E_PRECISION */
526 shift = mantissa_bits - shift;
531 /* Store the mantissa data into smant and the roundbit into rbit */
532 for (p = flonum.leader; p >= flonum.low && shift > -16; p--)
534 tmp = shift >= 0 ? *p << shift : *p >> -shift;
535 rbit = shift < 0 ? ((*p >> (-shift-1)) & 0x1) : 0;
540 /* OK, we've got our scaled mantissa so let's round it up */
543 /* If the mantissa is going to overflow when added, lets store
544 the extra bit in mover. -- A special case exists when
545 mantissa_bits is 31 (E_PRECISION). Then the first test cannot
546 be trusted, as result is host-dependent, thus the second
548 if( smant == ((unsigned)(1<<(mantissa_bits+1))-1)
549 || smant == (unsigned)-1 ) /* This is to catch E_PRECISION cases */
554 /* Get the scaled one value */
555 sone = (1 << (mantissa_bits));
557 /* The number may be unnormalised so renormalise it... */
561 smant |= sone; /* Insert the bit from mover into smant */
565 /* The binary point is now between bit positions 11 and 10 or 23 and 22,
566 i.e., between mantissa_bits - 1 and mantissa_bits - 2 and the
567 bit at mantissa_bits - 1 should be set. */
569 abort (); /* Ooops. */
571 if (flonum.sign == '+')
572 sfract = smant - sone; /* smant - 1.0. */
575 /* This seems to work. */
583 sfract = -smant & (sone-1); /* 2.0 - smant. */
585 sfract |= sone; /* Insert sign bit. */
588 if (abs (exponent) >= (1 << (exponent_bits - 1)))
589 as_bad ("Cannot represent exponent in %d bits", exponent_bits);
591 /* Force exponent to fit in desired field width. */
592 exponent &= (1 << (exponent_bits)) - 1;
594 if (precision == E_PRECISION)
596 /* Map the float part first (100% equal format as F_PRECISION) */
597 words[0] = exponent << (mantissa_bits+1-24);
598 words[0] |= sfract >> 24;
599 words[1] = sfract >> 8;
601 /* Map the mantissa in the next */
602 words[2] = sfract >> 16;
603 words[3] = sfract & 0xffff;
607 /* Insert the exponent data into the word */
608 sfract |= exponent << (mantissa_bits+1);
610 if (precision == S_PRECISION)
614 words[0] = sfract >> 16;
615 words[1] = sfract & 0xffff;
622 /* Returns pointer past text consumed. */
624 c4x_atof (str, what_kind, words)
627 LITTLENUM_TYPE *words;
629 /* Extra bits for zeroed low-order bits. The 1st MAX_PRECISION are
630 zeroed, the last contain flonum bits. */
631 static LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
633 /* Number of 16-bit words in the format. */
635 FLONUM_TYPE save_gen_flonum;
637 /* We have to save the generic_floating_point_number because it
638 contains storage allocation about the array of LITTLENUMs where
639 the value is actually stored. We will allocate our own array of
640 littlenums below, but have to restore the global one on exit. */
641 save_gen_flonum = generic_floating_point_number;
644 generic_floating_point_number.low = bits + MAX_PRECISION;
645 generic_floating_point_number.high = NULL;
646 generic_floating_point_number.leader = NULL;
647 generic_floating_point_number.exponent = 0;
648 generic_floating_point_number.sign = '\0';
650 /* Use more LittleNums than seems necessary: the highest flonum may
651 have 15 leading 0 bits, so could be useless. */
653 memset (bits, '\0', sizeof (LITTLENUM_TYPE) * MAX_PRECISION);
659 precision = S_PRECISION;
666 precision = F_PRECISION;
671 precision = E_PRECISION;
675 as_bad ("Invalid floating point number");
679 generic_floating_point_number.high
680 = generic_floating_point_number.low + precision - 1 + GUARD;
682 if (atof_generic (&return_value, ".", EXP_CHARS,
683 &generic_floating_point_number))
685 as_bad ("Invalid floating point number");
689 c4x_gen_to_words (generic_floating_point_number,
692 /* Restore the generic_floating_point_number's storage alloc (and
694 generic_floating_point_number = save_gen_flonum;
700 c4x_insert_reg (regname, regnum)
707 symbol_table_insert (symbol_new (regname, reg_section, (valueT) regnum,
708 &zero_address_frag));
709 for (i = 0; regname[i]; i++)
710 buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i];
713 symbol_table_insert (symbol_new (buf, reg_section, (valueT) regnum,
714 &zero_address_frag));
718 c4x_insert_sym (symname, value)
724 symbolP = symbol_new (symname, absolute_section,
725 (valueT) value, &zero_address_frag);
726 SF_SET_LOCAL (symbolP);
727 symbol_table_insert (symbolP);
731 c4x_expression (str, exp)
738 t = input_line_pointer; /* Save line pointer. */
739 input_line_pointer = str;
741 s = input_line_pointer;
742 input_line_pointer = t; /* Restore line pointer. */
743 return s; /* Return pointer to where parsing stopped. */
747 c4x_expression_abs (str, value)
754 t = input_line_pointer; /* Save line pointer. */
755 input_line_pointer = str;
756 *value = get_absolute_expression ();
757 s = input_line_pointer;
758 input_line_pointer = t; /* Restore line pointer. */
769 exp.X_op = O_constant;
770 exp.X_add_number = c;
775 c4x_seg_alloc (name, seg, size, symbolP)
776 char *name ATTRIBUTE_UNUSED;
777 segT seg ATTRIBUTE_UNUSED;
781 /* Note that the size is in words
782 so we multiply it by 4 to get the number of bytes to allocate. */
784 /* If we have symbol: .usect ".fred", size etc.,
785 the symbol needs to point to the first location reserved
792 p = frag_var (rs_fill, 1, 1, (relax_substateT) 0,
794 size * OCTETS_PER_BYTE, (char *) 0);
799 /* .asg ["]character-string["], symbol */
802 int x ATTRIBUTE_UNUSED;
810 str = input_line_pointer;
812 /* Skip string expression. */
813 while (*input_line_pointer != ',' && *input_line_pointer)
814 input_line_pointer++;
815 if (*input_line_pointer != ',')
817 as_bad ("Comma expected\n");
820 *input_line_pointer++ = '\0';
821 name = input_line_pointer;
822 c = get_symbol_end (); /* Get terminator. */
823 tmp = xmalloc (strlen (str) + 1);
826 tmp = xmalloc (strlen (name) + 1);
829 if (hash_find (c4x_asg_hash, name))
830 hash_replace (c4x_asg_hash, name, (PTR) str);
832 hash_insert (c4x_asg_hash, name, (PTR) str);
833 *input_line_pointer = c;
834 demand_empty_rest_of_line ();
837 /* .bss symbol, size */
840 int x ATTRIBUTE_UNUSED;
847 subsegT current_subseg;
850 current_seg = now_seg; /* Save current seg. */
851 current_subseg = now_subseg; /* Save current subseg. */
854 name = input_line_pointer;
855 c = get_symbol_end (); /* Get terminator. */
858 as_bad (".bss size argument missing\n");
863 c4x_expression_abs (++input_line_pointer, &size);
866 as_bad (".bss size %d < 0!", size);
869 subseg_set (bss_section, 0);
870 symbolP = symbol_find_or_make (name);
872 if (S_GET_SEGMENT (symbolP) == bss_section)
873 symbol_get_frag (symbolP)->fr_symbol = 0;
875 symbol_set_frag (symbolP, frag_now);
877 p = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,
878 size * OCTETS_PER_BYTE, (char *) 0);
879 *p = 0; /* Fill char. */
881 S_SET_SEGMENT (symbolP, bss_section);
883 /* The symbol may already have been created with a preceding
884 ".globl" directive -- be careful not to step on storage class
885 in that case. Otherwise, set it to static. */
886 if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
887 S_SET_STORAGE_CLASS (symbolP, C_STAT);
889 subseg_set (current_seg, current_subseg); /* Restore current seg. */
890 demand_empty_rest_of_line ();
895 int ignore ATTRIBUTE_UNUSED;
903 name = input_line_pointer;
904 c = get_symbol_end ();
905 symbolP = symbol_find_or_make (name);
906 *input_line_pointer = c;
908 S_SET_STORAGE_CLASS (symbolP, C_EXT);
911 input_line_pointer++;
913 if (*input_line_pointer == '\n')
919 demand_empty_rest_of_line ();
922 /* Handle .byte, .word. .int, .long */
927 register unsigned int c;
931 if (*input_line_pointer == '"')
933 input_line_pointer++;
934 while (is_a_char (c = next_char_of_string ()))
935 c4x_emit_char (c, 4);
936 know (input_line_pointer[-1] == '\"');
942 input_line_pointer = c4x_expression (input_line_pointer, &exp);
943 if (exp.X_op == O_constant)
948 exp.X_add_number &= 255;
951 exp.X_add_number &= 65535;
955 /* Perhaps we should disallow .byte and .hword with
956 a non constant expression that will require relocation. */
960 while (*input_line_pointer++ == ',');
962 input_line_pointer--; /* Put terminator back into stream. */
963 demand_empty_rest_of_line ();
966 /* Handle .ascii, .asciz, .string */
968 c4x_stringer (append_zero)
969 int append_zero; /*ex: bytes */
972 register unsigned int c;
978 if (*input_line_pointer == '"')
980 input_line_pointer++;
981 while (is_a_char (c = next_char_of_string ()))
983 c4x_emit_char (c, 1);
989 c4x_emit_char (c, 1);
993 know (input_line_pointer[-1] == '\"');
999 input_line_pointer = c4x_expression (input_line_pointer, &exp);
1000 if (exp.X_op != O_constant)
1002 as_bad("Non-constant symbols not allowed\n");
1005 exp.X_add_number &= 255; /* Limit numeber to 8-bit */
1006 emit_expr (&exp, 1);
1010 while (*input_line_pointer++ == ',');
1012 /* Fill out the rest of the expression with 0's to fill up a full word */
1014 c4x_emit_char (0, 4-(bytes&0x3));
1016 input_line_pointer--; /* Put terminator back into stream. */
1017 demand_empty_rest_of_line ();
1020 /* .eval expression, symbol */
1023 int x ATTRIBUTE_UNUSED;
1030 input_line_pointer =
1031 c4x_expression_abs (input_line_pointer, &value);
1032 if (*input_line_pointer++ != ',')
1034 as_bad ("Symbol missing\n");
1037 name = input_line_pointer;
1038 c = get_symbol_end (); /* Get terminator. */
1039 demand_empty_rest_of_line ();
1040 c4x_insert_sym (name, value);
1043 /* Reset local labels. */
1046 int x ATTRIBUTE_UNUSED;
1048 dollar_label_clear ();
1051 /* .sect "section-name" [, value] */
1052 /* .sect ["]section-name[:subsection-name]["] [, value] */
1055 int x ATTRIBUTE_UNUSED;
1059 char *subsection_name;
1065 if (*input_line_pointer == '"')
1066 input_line_pointer++;
1067 section_name = input_line_pointer;
1068 c = get_symbol_end (); /* Get terminator. */
1069 input_line_pointer++; /* Skip null symbol terminator. */
1070 name = xmalloc (input_line_pointer - section_name + 1);
1071 strcpy (name, section_name);
1073 /* TI C from version 5.0 allows a section name to contain a
1074 subsection name as well. The subsection name is separated by a
1075 ':' from the section name. Currently we scan the subsection
1076 name and discard it.
1077 Volker Kuhlmann <v.kuhlmann@elec.canterbury.ac.nz>. */
1080 subsection_name = input_line_pointer;
1081 c = get_symbol_end (); /* Get terminator. */
1082 input_line_pointer++; /* Skip null symbol terminator. */
1083 as_warn (".sect: subsection name ignored");
1086 /* We might still have a '"' to discard, but the character after a
1087 symbol name will be overwritten with a \0 by get_symbol_end()
1091 input_line_pointer =
1092 c4x_expression_abs (input_line_pointer, &num);
1093 else if (*input_line_pointer == ',')
1095 input_line_pointer =
1096 c4x_expression_abs (++input_line_pointer, &num);
1101 seg = subseg_new (name, num);
1102 if (line_label != NULL)
1104 S_SET_SEGMENT (line_label, seg);
1105 symbol_set_frag (line_label, frag_now);
1108 if (bfd_get_section_flags (stdoutput, seg) == SEC_NO_FLAGS)
1110 if (!bfd_set_section_flags (stdoutput, seg, SEC_DATA))
1111 as_warn ("Error setting flags for \"%s\": %s", name,
1112 bfd_errmsg (bfd_get_error ()));
1115 /* If the last character overwritten by get_symbol_end() was an
1116 end-of-line, we must restore it or the end of the line will not be
1117 recognised and scanning extends into the next line, stopping with
1118 an error (blame Volker Kuhlmann <v.kuhlmann@elec.canterbury.ac.nz>
1119 if this is not true). */
1120 if (is_end_of_line[(unsigned char) c])
1121 *(--input_line_pointer) = c;
1123 demand_empty_rest_of_line ();
1126 /* symbol[:] .set value or .set symbol, value */
1129 int x ATTRIBUTE_UNUSED;
1134 if ((symbolP = line_label) == NULL)
1139 name = input_line_pointer;
1140 c = get_symbol_end (); /* Get terminator. */
1143 as_bad (".set syntax invalid\n");
1144 ignore_rest_of_line ();
1147 symbolP = symbol_find_or_make (name);
1150 symbol_table_insert (symbolP);
1152 pseudo_set (symbolP);
1153 demand_empty_rest_of_line ();
1156 /* [symbol] .usect ["]section-name["], size-in-words [, alignment-flag] */
1159 int x ATTRIBUTE_UNUSED;
1165 int size, alignment_flag;
1167 subsegT current_subseg;
1169 current_seg = now_seg; /* save current seg. */
1170 current_subseg = now_subseg; /* save current subseg. */
1173 if (*input_line_pointer == '"')
1174 input_line_pointer++;
1175 section_name = input_line_pointer;
1176 c = get_symbol_end (); /* Get terminator. */
1177 input_line_pointer++; /* Skip null symbol terminator. */
1178 name = xmalloc (input_line_pointer - section_name + 1);
1179 strcpy (name, section_name);
1182 input_line_pointer =
1183 c4x_expression_abs (input_line_pointer, &size);
1184 else if (*input_line_pointer == ',')
1186 input_line_pointer =
1187 c4x_expression_abs (++input_line_pointer, &size);
1192 /* Read a possibly present third argument (alignment flag) [VK]. */
1193 if (*input_line_pointer == ',')
1195 input_line_pointer =
1196 c4x_expression_abs (++input_line_pointer, &alignment_flag);
1201 as_warn (".usect: non-zero alignment flag ignored");
1203 seg = subseg_new (name, 0);
1204 if (line_label != NULL)
1206 S_SET_SEGMENT (line_label, seg);
1207 symbol_set_frag (line_label, frag_now);
1208 S_SET_VALUE (line_label, frag_now_fix ());
1210 seg_info (seg)->bss = 1; /* Uninitialised data. */
1211 if (!bfd_set_section_flags (stdoutput, seg, SEC_ALLOC))
1212 as_warn ("Error setting flags for \"%s\": %s", name,
1213 bfd_errmsg (bfd_get_error ()));
1214 c4x_seg_alloc (name, seg, size, line_label);
1216 if (S_GET_STORAGE_CLASS (line_label) != C_EXT)
1217 S_SET_STORAGE_CLASS (line_label, C_STAT);
1219 subseg_set (current_seg, current_subseg); /* Restore current seg. */
1220 demand_empty_rest_of_line ();
1223 /* .version cpu-version. */
1226 int x ATTRIBUTE_UNUSED;
1230 input_line_pointer =
1231 c4x_expression_abs (input_line_pointer, &temp);
1232 if (!IS_CPU_C3X (temp) && !IS_CPU_C4X (temp))
1233 as_bad ("This assembler does not support processor generation %d\n",
1236 if (c4x_cpu && temp != c4x_cpu)
1237 as_warn ("Changing processor generation on fly not supported...\n");
1239 demand_empty_rest_of_line ();
1243 c4x_init_regtable ()
1247 for (i = 0; i < c3x_num_registers; i++)
1248 c4x_insert_reg (c3x_registers[i].name,
1249 c3x_registers[i].regno);
1251 if (IS_CPU_C4X (c4x_cpu))
1253 /* Add additional C4x registers, overriding some C3x ones. */
1254 for (i = 0; i < c4x_num_registers; i++)
1255 c4x_insert_reg (c4x_registers[i].name,
1256 c4x_registers[i].regno);
1263 /* The TI tools accept case insensitive versions of these symbols,
1268 .TMS320xx 30,31,32,40,or 44 set according to -v flag
1269 .C3X or .C3x 1 or 0 1 if -v30,-v31,or -v32
1270 .C30 1 or 0 1 if -v30
1271 .C31 1 or 0 1 if -v31
1272 .C32 1 or 0 1 if -v32
1273 .C4X or .C4x 1 or 0 1 if -v40, or -v44
1274 .C40 1 or 0 1 if -v40
1275 .C44 1 or 0 1 if -v44
1277 .REGPARM 1 or 0 1 if -mr option used
1278 .BIGMODEL 1 or 0 1 if -mb option used
1280 These symbols are currently supported but will be removed in a
1282 .TMS320C30 1 or 0 1 if -v30,-v31,or -v32
1283 .TMS320C31 1 or 0 1 if -v31
1284 .TMS320C32 1 or 0 1 if -v32
1285 .TMS320C40 1 or 0 1 if -v40, or -v44
1286 .TMS320C44 1 or 0 1 if -v44
1288 Source: TI: TMS320C3x/C4x Assembly Language Tools User's Guide,
1289 1997, SPRU035C, p. 3-17/3-18. */
1290 c4x_insert_sym (".REGPARM", c4x_reg_args);
1291 c4x_insert_sym (".MEMPARM", !c4x_reg_args);
1292 c4x_insert_sym (".BIGMODEL", c4x_big_model);
1293 c4x_insert_sym (".C30INTERRUPT", 0);
1294 c4x_insert_sym (".TMS320xx", c4x_cpu == 0 ? 40 : c4x_cpu);
1295 c4x_insert_sym (".C3X", c4x_cpu == 30 || c4x_cpu == 31 || c4x_cpu == 32 || c4x_cpu == 33);
1296 c4x_insert_sym (".C3x", c4x_cpu == 30 || c4x_cpu == 31 || c4x_cpu == 32 || c4x_cpu == 33);
1297 c4x_insert_sym (".C4X", c4x_cpu == 0 || c4x_cpu == 40 || c4x_cpu == 44);
1298 c4x_insert_sym (".C4x", c4x_cpu == 0 || c4x_cpu == 40 || c4x_cpu == 44);
1299 /* Do we need to have the following symbols also in lower case? */
1300 c4x_insert_sym (".TMS320C30", c4x_cpu == 30 || c4x_cpu == 31 || c4x_cpu == 32 || c4x_cpu == 33);
1301 c4x_insert_sym (".tms320C30", c4x_cpu == 30 || c4x_cpu == 31 || c4x_cpu == 32 || c4x_cpu == 33);
1302 c4x_insert_sym (".TMS320C31", c4x_cpu == 31);
1303 c4x_insert_sym (".tms320C31", c4x_cpu == 31);
1304 c4x_insert_sym (".TMS320C32", c4x_cpu == 32);
1305 c4x_insert_sym (".tms320C32", c4x_cpu == 32);
1306 c4x_insert_sym (".TMS320C33", c4x_cpu == 33);
1307 c4x_insert_sym (".tms320C33", c4x_cpu == 33);
1308 c4x_insert_sym (".TMS320C40", c4x_cpu == 40 || c4x_cpu == 44 || c4x_cpu == 0);
1309 c4x_insert_sym (".tms320C40", c4x_cpu == 40 || c4x_cpu == 44 || c4x_cpu == 0);
1310 c4x_insert_sym (".TMS320C44", c4x_cpu == 44);
1311 c4x_insert_sym (".tms320C44", c4x_cpu == 44);
1312 c4x_insert_sym (".TMX320C40", 0); /* C40 first pass silicon ? */
1313 c4x_insert_sym (".tmx320C40", 0);
1316 /* Insert a new instruction template into hash table. */
1318 c4x_inst_insert (inst)
1321 static char prev_name[16];
1322 const char *retval = NULL;
1324 /* Only insert the first name if have several similar entries. */
1325 if (!strcmp (inst->name, prev_name) || inst->name[0] == '\0')
1328 retval = hash_insert (c4x_op_hash, inst->name, (PTR) inst);
1330 fprintf (stderr, "internal error: can't hash `%s': %s\n",
1331 inst->name, retval);
1333 strcpy (prev_name, inst->name);
1334 return retval == NULL;
1337 /* Make a new instruction template. */
1339 c4x_inst_make (name, opcode, args)
1341 unsigned long opcode;
1344 static c4x_inst_t *insts = NULL;
1345 static char *names = NULL;
1346 static int index = 0;
1350 /* Allocate memory to store name strings. */
1351 names = (char *) xmalloc (sizeof (char) * 8192);
1352 /* Allocate memory for additional insts. */
1353 insts = (c4x_inst_t *)
1354 xmalloc (sizeof (c4x_inst_t) * 1024);
1356 insts[index].name = names;
1357 insts[index].opcode = opcode;
1358 insts[index].opmask = 0xffffffff;
1359 insts[index].args = args;
1367 return &insts[index - 1];
1370 /* Add instruction template, creating dynamic templates as required. */
1372 c4x_inst_add (insts)
1375 char *s = insts->name;
1389 /* Dynamically create all the conditional insts. */
1390 for (i = 0; i < num_conds; i++)
1394 char *c = c4x_conds[i].name;
1404 /* If instruction found then have already processed it. */
1405 if (hash_find (c4x_op_hash, name))
1410 inst = c4x_inst_make (name, insts[k].opcode +
1411 (c4x_conds[i].cond <<
1412 (*s == 'B' ? 16 : 23)),
1414 if (k == 0) /* Save strcmp() with following func. */
1415 ok &= c4x_inst_insert (inst);
1418 while (!strcmp (insts->name,
1425 return c4x_inst_insert (insts);
1435 /* This function is called once, at assembler startup time. It should
1436 set up all the tables, etc., that the MD part of the assembler will
1444 /* Create hash table for mnemonics. */
1445 c4x_op_hash = hash_new ();
1447 /* Create hash table for asg pseudo. */
1448 c4x_asg_hash = hash_new ();
1450 /* Add mnemonics to hash table, expanding conditional mnemonics on fly. */
1451 for (i = 0; i < c3x_num_insts; i++)
1452 ok &= c4x_inst_add ((void *) &c3x_insts[i]);
1454 if (IS_CPU_C4X (c4x_cpu))
1456 for (i = 0; i < c4x_num_insts; i++)
1457 ok &= c4x_inst_add ((void *) &c4x_insts[i]);
1460 /* Create dummy inst to avoid errors accessing end of table. */
1461 c4x_inst_make ("", 0, "");
1464 as_fatal ("Broken assembler. No assembly attempted.");
1466 /* Add registers to symbol table. */
1467 c4x_init_regtable ();
1469 /* Add predefined symbols to symbol table. */
1470 c4x_init_symbols ();
1476 bfd_set_arch_mach (stdoutput, bfd_arch_tic4x,
1477 IS_CPU_C4X (c4x_cpu) ? bfd_mach_c4x : bfd_mach_c3x);
1481 c4x_indirect_parse (operand, indirect)
1482 c4x_operand_t *operand;
1483 const c4x_indirect_t *indirect;
1485 char *n = indirect->name;
1486 char *s = input_line_pointer;
1496 case 'a': /* Need to match aux register. */
1498 #ifdef C4X_ALT_SYNTAX
1502 while (isalnum (*s))
1505 if (!(symbolP = symbol_find (name)))
1508 if (S_GET_SEGMENT (symbolP) != reg_section)
1511 operand->aregno = S_GET_VALUE (symbolP);
1512 if (operand->aregno >= REG_AR0 && operand->aregno <= REG_AR7)
1515 as_bad ("Auxiliary register AR0--AR7 required for indirect");
1518 case 'd': /* Need to match constant for disp. */
1519 #ifdef C4X_ALT_SYNTAX
1520 if (*s == '%') /* expr() will die if we don't skip this. */
1523 s = c4x_expression (s, &operand->expr);
1524 if (operand->expr.X_op != O_constant)
1526 operand->disp = operand->expr.X_add_number;
1527 if (operand->disp < 0 || operand->disp > 255)
1529 as_bad ("Bad displacement %d (require 0--255)\n",
1535 case 'y': /* Need to match IR0. */
1536 case 'z': /* Need to match IR1. */
1537 #ifdef C4X_ALT_SYNTAX
1541 s = c4x_expression (s, &operand->expr);
1542 if (operand->expr.X_op != O_register)
1544 if (operand->expr.X_add_number != REG_IR0
1545 && operand->expr.X_add_number != REG_IR1)
1547 as_bad ("Index register IR0,IR1 required for displacement");
1551 if (*n == 'y' && operand->expr.X_add_number == REG_IR0)
1553 if (*n == 'z' && operand->expr.X_add_number == REG_IR1)
1558 if (*s != '(') /* No displacement, assume to be 1. */
1569 if (tolower (*s) != *n)
1574 if (*s != ' ' && *s != ',' && *s != '\0')
1576 input_line_pointer = s;
1581 c4x_operand_parse (s, operand)
1583 c4x_operand_t *operand;
1588 expressionS *exp = &operand->expr;
1589 char *save = input_line_pointer;
1592 struct hash_entry *entry = NULL;
1594 input_line_pointer = s;
1597 str = input_line_pointer;
1598 c = get_symbol_end (); /* Get terminator. */
1599 new = input_line_pointer;
1600 if (strlen (str) && (entry = hash_find (c4x_asg_hash, str)) != NULL)
1602 *input_line_pointer = c;
1603 input_line_pointer = (char *) entry;
1607 *input_line_pointer = c;
1608 input_line_pointer = str;
1611 operand->mode = M_UNKNOWN;
1612 switch (*input_line_pointer)
1614 #ifdef C4X_ALT_SYNTAX
1616 input_line_pointer = c4x_expression (++input_line_pointer, exp);
1617 if (exp->X_op != O_register)
1618 as_bad ("Expecting a register name");
1619 operand->mode = M_REGISTER;
1623 /* Denotes high 16 bits. */
1624 input_line_pointer = c4x_expression (++input_line_pointer, exp);
1625 if (exp->X_op == O_constant)
1626 operand->mode = M_IMMED;
1627 else if (exp->X_op == O_big)
1629 if (exp->X_add_number)
1630 as_bad ("Number too large"); /* bignum required */
1633 c4x_gen_to_words (generic_floating_point_number,
1634 operand->fwords, S_PRECISION);
1635 operand->mode = M_IMMED_F;
1638 /* Allow ori ^foo, ar0 to be equivalent to ldi .hi.foo, ar0 */
1639 /* WARNING : The TI C40 assembler cannot do this. */
1640 else if (exp->X_op == O_symbol)
1642 operand->mode = M_HI;
1647 input_line_pointer = c4x_expression (++input_line_pointer, exp);
1648 if (exp->X_op == O_constant)
1649 operand->mode = M_IMMED;
1650 else if (exp->X_op == O_big)
1652 if (exp->X_add_number > 0)
1653 as_bad ("Number too large"); /* bignum required. */
1656 c4x_gen_to_words (generic_floating_point_number,
1657 operand->fwords, S_PRECISION);
1658 operand->mode = M_IMMED_F;
1661 /* Allow ori foo, ar0 to be equivalent to ldi .lo.foo, ar0 */
1662 /* WARNING : The TI C40 assembler cannot do this. */
1663 else if (exp->X_op == O_symbol)
1665 operand->mode = M_IMMED;
1670 as_bad ("Expecting a constant value");
1675 input_line_pointer = c4x_expression (++input_line_pointer, exp);
1676 if (exp->X_op != O_constant && exp->X_op != O_symbol)
1677 as_bad ("Bad direct addressing construct %s", s);
1678 if (exp->X_op == O_constant)
1680 if (exp->X_add_number < 0)
1681 as_bad ("Direct value of %ld is not suitable",
1682 (long) exp->X_add_number);
1684 operand->mode = M_DIRECT;
1689 for (i = 0; i < num_indirects; i++)
1690 if ((ret = c4x_indirect_parse (operand, &c4x_indirects[i])))
1694 if (i < num_indirects)
1696 operand->mode = M_INDIRECT;
1697 /* Indirect addressing mode number. */
1698 operand->expr.X_add_number = c4x_indirects[i].modn;
1699 /* Convert *+ARn(0) to *ARn etc. Maybe we should
1700 squeal about silly ones? */
1701 if (operand->expr.X_add_number < 0x08 && !operand->disp)
1702 operand->expr.X_add_number = 0x18;
1705 as_bad ("Unknown indirect addressing mode");
1709 operand->mode = M_IMMED; /* Assume immediate. */
1710 str = input_line_pointer;
1711 input_line_pointer = c4x_expression (input_line_pointer, exp);
1712 if (exp->X_op == O_register)
1714 know (exp->X_add_symbol == 0);
1715 know (exp->X_op_symbol == 0);
1716 operand->mode = M_REGISTER;
1719 else if (exp->X_op == O_big)
1721 if (exp->X_add_number > 0)
1722 as_bad ("Number too large"); /* bignum required. */
1725 c4x_gen_to_words (generic_floating_point_number,
1726 operand->fwords, S_PRECISION);
1727 operand->mode = M_IMMED_F;
1731 #ifdef C4X_ALT_SYNTAX
1732 /* Allow ldi foo, ar0 to be equivalent to ldi @foo, ar0. */
1733 else if (exp->X_op == O_symbol)
1735 operand->mode = M_DIRECT;
1741 new = input_line_pointer;
1742 input_line_pointer = save;
1747 c4x_operands_match (inst, insn)
1751 const char *args = inst->args;
1752 unsigned long opcode = inst->opcode;
1753 int num_operands = insn->num_operands;
1754 c4x_operand_t *operand = insn->operands;
1755 expressionS *exp = &operand->expr;
1759 /* Build the opcode, checking as we go to make sure that the
1762 If an operand matches, we modify insn or opcode appropriately,
1763 and do a "continue". If an operand fails to match, we "break". */
1765 insn->nchars = 4; /* Instructions always 4 bytes. */
1766 insn->reloc = NO_RELOC;
1771 insn->opcode = opcode;
1772 return num_operands == 0;
1780 case '\0': /* End of args. */
1781 if (num_operands == 1)
1783 insn->opcode = opcode;
1786 break; /* Too many operands. */
1788 case '#': /* This is only used for ldp. */
1789 if (operand->mode != M_DIRECT && operand->mode != M_IMMED)
1791 /* While this looks like a direct addressing mode, we actually
1792 use an immediate mode form of ldiu or ldpk instruction. */
1793 if (exp->X_op == O_constant)
1795 /* Maybe for C3x we should check for 8 bit number. */
1796 INSERTS (opcode, exp->X_add_number, 15, 0);
1799 else if (exp->X_op == O_symbol)
1801 insn->reloc = BFD_RELOC_HI16;
1805 break; /* Not direct (dp) addressing. */
1807 case '@': /* direct. */
1808 if (operand->mode != M_DIRECT)
1810 if (exp->X_op == O_constant)
1812 /* Store only the 16 LSBs of the number. */
1813 INSERTS (opcode, exp->X_add_number, 15, 0);
1816 else if (exp->X_op == O_symbol)
1818 insn->reloc = BFD_RELOC_LO16;
1822 break; /* Not direct addressing. */
1825 if (operand->mode != M_REGISTER)
1827 reg = exp->X_add_number;
1828 if (reg >= REG_AR0 && reg <= REG_AR7)
1829 INSERTU (opcode, reg - REG_AR0, 24, 22);
1832 as_bad ("Destination register must be ARn");
1837 case 'B': /* Unsigned integer immediate. */
1838 /* Allow br label or br @label. */
1839 if (operand->mode != M_IMMED && operand->mode != M_DIRECT)
1841 if (exp->X_op == O_constant)
1843 if (exp->X_add_number < (1 << 24))
1845 INSERTU (opcode, exp->X_add_number, 23, 0);
1850 as_bad ("Immediate value of %ld is too large",
1851 (long) exp->X_add_number);
1856 if (IS_CPU_C4X (c4x_cpu))
1858 insn->reloc = BFD_RELOC_24_PCREL;
1863 insn->reloc = BFD_RELOC_24;
1870 if (!IS_CPU_C4X (c4x_cpu))
1872 if (operand->mode != M_INDIRECT)
1874 if (operand->expr.X_add_number != 0
1875 && operand->expr.X_add_number != 0x18)
1877 as_bad ("Invalid indirect addressing mode");
1881 INSERTU (opcode, operand->aregno - REG_AR0, 2, 0);
1882 INSERTU (opcode, operand->disp, 7, 3);
1886 if (!(operand->mode == M_REGISTER))
1888 INSERTU (opcode, exp->X_add_number, 7, 0);
1892 if (operand->mode != M_IMMED_F
1893 && !(operand->mode == M_IMMED && exp->X_op == O_constant))
1896 if (operand->mode != M_IMMED_F)
1898 /* OK, we 've got something like cmpf 0, r0
1899 Why can't they stick in a bloody decimal point ?! */
1902 /* Create floating point number string. */
1903 sprintf (string, "%d.0", (int) exp->X_add_number);
1904 c4x_atof (string, 's', operand->fwords);
1907 INSERTU (opcode, operand->fwords[0], 15, 0);
1911 if (operand->mode != M_REGISTER)
1913 INSERTU (opcode, exp->X_add_number, 15, 8);
1917 if (operand->mode != M_REGISTER)
1919 reg = exp->X_add_number;
1920 if (reg >= REG_R0 && reg <= REG_R7)
1921 INSERTU (opcode, reg - REG_R0, 18, 16);
1924 as_bad ("Register must be R0--R7");
1930 if (operand->mode != M_INDIRECT)
1932 if (operand->disp != 0 && operand->disp != 1)
1934 if (IS_CPU_C4X (c4x_cpu))
1936 as_bad ("Invalid indirect addressing mode displacement %d",
1941 INSERTU (opcode, operand->aregno - REG_AR0, 2, 0);
1942 INSERTU (opcode, operand->expr.X_add_number, 7, 3);
1946 if (operand->mode != M_INDIRECT)
1948 if (operand->disp != 0 && operand->disp != 1)
1950 if (IS_CPU_C4X (c4x_cpu))
1952 as_bad ("Invalid indirect addressing mode displacement %d",
1957 INSERTU (opcode, operand->aregno - REG_AR0, 10, 8);
1958 INSERTU (opcode, operand->expr.X_add_number, 15, 11);
1962 if (operand->mode != M_REGISTER)
1964 reg = exp->X_add_number;
1965 if (reg >= REG_R0 && reg <= REG_R7)
1966 INSERTU (opcode, reg - REG_R0, 21, 19);
1969 as_bad ("Register must be R0--R7");
1975 if (operand->mode != M_REGISTER)
1977 reg = exp->X_add_number;
1978 if (reg >= REG_R0 && reg <= REG_R7)
1979 INSERTU (opcode, reg - REG_R0, 24, 22);
1982 as_bad ("Register must be R0--R7");
1988 if (operand->mode != M_REGISTER)
1990 reg = exp->X_add_number;
1991 if (reg == REG_R2 || reg == REG_R3)
1992 INSERTU (opcode, reg - REG_R2, 22, 22);
1995 as_bad ("Destination register must be R2 or R3");
2001 if (operand->mode != M_REGISTER)
2003 reg = exp->X_add_number;
2004 if (reg == REG_R0 || reg == REG_R1)
2005 INSERTU (opcode, reg - REG_R0, 23, 23);
2008 as_bad ("Destination register must be R0 or R1");
2014 if (!IS_CPU_C4X (c4x_cpu))
2016 if (operand->mode != M_INDIRECT)
2018 /* Require either *+ARn(disp) or *ARn. */
2019 if (operand->expr.X_add_number != 0
2020 && operand->expr.X_add_number != 0x18)
2022 as_bad ("Invalid indirect addressing mode");
2026 INSERTU (opcode, operand->aregno - REG_AR0, 10, 8);
2027 INSERTU (opcode, operand->disp, 15, 11);
2030 case 'P': /* PC relative displacement. */
2031 /* Allow br label or br @label. */
2032 if (operand->mode != M_IMMED && operand->mode != M_DIRECT)
2034 if (exp->X_op == O_constant)
2036 if (exp->X_add_number >= -32768 && exp->X_add_number <= 32767)
2038 INSERTS (opcode, exp->X_add_number, 15, 0);
2043 as_bad ("Displacement value of %ld is too large",
2044 (long) exp->X_add_number);
2049 insn->reloc = BFD_RELOC_16_PCREL;
2055 if (operand->mode != M_REGISTER)
2057 reg = exp->X_add_number;
2058 INSERTU (opcode, reg, 15, 0);
2062 if (operand->mode != M_REGISTER)
2064 reg = exp->X_add_number;
2065 INSERTU (opcode, reg, 20, 16);
2068 case 'S': /* Short immediate int. */
2069 if (operand->mode != M_IMMED && operand->mode != M_HI)
2071 if (exp->X_op == O_big)
2073 as_bad ("Floating point number not valid in expression");
2077 if (exp->X_op == O_constant)
2079 if (exp->X_add_number >= -32768 && exp->X_add_number <= 65535)
2081 INSERTS (opcode, exp->X_add_number, 15, 0);
2086 as_bad ("Signed immediate value %ld too large",
2087 (long) exp->X_add_number);
2092 else if (exp->X_op == O_symbol)
2094 if (operand->mode == M_HI)
2096 insn->reloc = BFD_RELOC_HI16;
2100 insn->reloc = BFD_RELOC_LO16;
2105 /* Handle cases like ldi foo - $, ar0 where foo
2106 is a forward reference. Perhaps we should check
2107 for X_op == O_symbol and disallow things like
2109 insn->reloc = BFD_RELOC_16;
2113 case 'T': /* 5-bit immediate value for c4x stik. */
2114 if (!IS_CPU_C4X (c4x_cpu))
2116 if (operand->mode != M_IMMED)
2118 if (exp->X_op == O_constant)
2120 if (exp->X_add_number < 16 && exp->X_add_number >= -16)
2122 INSERTS (opcode, exp->X_add_number, 20, 16);
2127 as_bad ("Immediate value of %ld is too large",
2128 (long) exp->X_add_number);
2133 break; /* No relocations allowed. */
2135 case 'U': /* Unsigned integer immediate. */
2136 if (operand->mode != M_IMMED && operand->mode != M_HI)
2138 if (exp->X_op == O_constant)
2140 if (exp->X_add_number < (1 << 16) && exp->X_add_number >= 0)
2142 INSERTU (opcode, exp->X_add_number, 15, 0);
2147 as_bad ("Unsigned immediate value %ld too large",
2148 (long) exp->X_add_number);
2153 else if (exp->X_op == O_symbol)
2155 if (operand->mode == M_HI)
2156 insn->reloc = BFD_RELOC_HI16;
2158 insn->reloc = BFD_RELOC_LO16;
2163 insn->reloc = BFD_RELOC_16;
2167 case 'V': /* Trap numbers (immediate field). */
2168 if (operand->mode != M_IMMED)
2170 if (exp->X_op == O_constant)
2172 if (exp->X_add_number < 512 && IS_CPU_C4X (c4x_cpu))
2174 INSERTU (opcode, exp->X_add_number, 8, 0);
2177 else if (exp->X_add_number < 32 && IS_CPU_C3X (c4x_cpu))
2179 INSERTU (opcode, exp->X_add_number | 0x20, 4, 0);
2184 as_bad ("Immediate value of %ld is too large",
2185 (long) exp->X_add_number);
2190 break; /* No relocations allowed. */
2192 case 'W': /* Short immediate int (0--7). */
2193 if (!IS_CPU_C4X (c4x_cpu))
2195 if (operand->mode != M_IMMED)
2197 if (exp->X_op == O_big)
2199 as_bad ("Floating point number not valid in expression");
2203 if (exp->X_op == O_constant)
2205 if (exp->X_add_number >= -256 && exp->X_add_number <= 127)
2207 INSERTS (opcode, exp->X_add_number, 7, 0);
2212 as_bad ("Immediate value %ld too large",
2213 (long) exp->X_add_number);
2218 insn->reloc = BFD_RELOC_16;
2222 case 'X': /* Expansion register for c4x. */
2223 if (operand->mode != M_REGISTER)
2225 reg = exp->X_add_number;
2226 if (reg >= REG_IVTP && reg <= REG_TVTP)
2227 INSERTU (opcode, reg - REG_IVTP, 4, 0);
2230 as_bad ("Register must be ivtp or tvtp");
2235 case 'Y': /* Address register for c4x lda. */
2236 if (operand->mode != M_REGISTER)
2238 reg = exp->X_add_number;
2239 if (reg >= REG_AR0 && reg <= REG_SP)
2240 INSERTU (opcode, reg, 20, 16);
2243 as_bad ("Register must be address register");
2248 case 'Z': /* Expansion register for c4x. */
2249 if (operand->mode != M_REGISTER)
2251 reg = exp->X_add_number;
2252 if (reg >= REG_IVTP && reg <= REG_TVTP)
2253 INSERTU (opcode, reg - REG_IVTP, 20, 16);
2256 as_bad ("Register must be ivtp or tvtp");
2262 if (operand->mode != M_INDIRECT)
2264 INSERTS (opcode, operand->disp, 7, 0);
2265 INSERTU (opcode, operand->aregno - REG_AR0, 10, 8);
2266 INSERTU (opcode, operand->expr.X_add_number, 15, 11);
2269 case '|': /* treat as `,' if have ldi_ldi form. */
2272 if (--num_operands < 0)
2273 break; /* Too few operands. */
2275 if (operand->mode != M_PARALLEL)
2280 case ',': /* Another operand. */
2281 if (--num_operands < 0)
2282 break; /* Too few operands. */
2284 exp = &operand->expr;
2287 case ';': /* Another optional operand. */
2288 if (num_operands == 1 || operand[1].mode == M_PARALLEL)
2290 if (--num_operands < 0)
2291 break; /* Too few operands. */
2293 exp = &operand->expr;
2304 c4x_insn_output (insn)
2309 /* Grab another fragment for opcode. */
2310 dst = frag_more (insn->nchars);
2312 /* Put out opcode word as a series of bytes in little endian order. */
2313 md_number_to_chars (dst, insn->opcode, insn->nchars);
2315 /* Put out the symbol-dependent stuff. */
2316 if (insn->reloc != NO_RELOC)
2318 /* Where is the offset into the fragment for this instruction. */
2319 fix_new_exp (frag_now,
2320 dst - frag_now->fr_literal, /* where */
2321 insn->nchars, /* size */
2328 /* Parse the operands. */
2330 c4x_operands_parse (s, operands, num_operands)
2332 c4x_operand_t *operands;
2336 return num_operands;
2339 s = c4x_operand_parse (s, &operands[num_operands++]);
2340 while (num_operands < C4X_OPERANDS_MAX && *s++ == ',');
2342 if (num_operands > C4X_OPERANDS_MAX)
2344 as_bad ("Too many operands scanned");
2347 return num_operands;
2350 /* Assemble a single instruction. Its label has already been handled
2351 by the generic front end. We just parse mnemonic and operands, and
2352 produce the bytes of data and relocation. */
2361 c4x_inst_t *inst; /* Instruction template. */
2363 if (str && insn->parallel)
2367 /* Find mnemonic (second part of parallel instruction). */
2369 /* Skip past instruction mnemonic. */
2370 while (*s && *s != ' ' && *s != '*')
2373 if (*s) /* Null terminate for hash_find. */
2374 *s++ = '\0'; /* and skip past null. */
2375 strcat (insn->name, "_");
2376 strncat (insn->name, str, C4X_NAME_MAX - strlen (insn->name));
2378 /* Kludge to overcome problems with scrubber removing
2379 space between mnemonic and indirect operand (starting with *)
2380 on second line of parallel instruction. */
2384 insn->operands[insn->num_operands++].mode = M_PARALLEL;
2386 if ((i = c4x_operands_parse
2387 (s, insn->operands, insn->num_operands)) < 0)
2393 insn->num_operands = i;
2399 if ((insn->inst = (struct c4x_inst *)
2400 hash_find (c4x_op_hash, insn->name)) == NULL)
2402 as_bad ("Unknown opcode `%s'.", insn->name);
2408 /* FIXME: The list of templates should be scanned
2409 for the candidates with the desired number of operands.
2410 We shouldn't issue error messages until we have
2411 whittled the list of candidate templates to the most
2412 likely one... We could cache a parsed form of the templates
2413 to reduce the time required to match a template. */
2418 ok = c4x_operands_match (inst, insn);
2419 while (!ok && !strcmp (inst->name, inst[1].name) && inst++);
2422 c4x_insn_output (insn);
2424 as_bad ("Invalid operands for %s", insn->name);
2426 as_bad ("Invalid instruction %s", insn->name);
2431 /* Find mnemonic. */
2433 while (*s && *s != ' ') /* Skip past instruction mnemonic. */
2435 if (*s) /* Null terminate for hash_find. */
2436 *s++ = '\0'; /* and skip past null. */
2437 strncpy (insn->name, str, C4X_NAME_MAX - 3);
2439 if ((i = c4x_operands_parse (s, insn->operands, 0)) < 0)
2441 insn->inst = NULL; /* Flag that error occured. */
2446 insn->num_operands = i;
2461 /* Turn a string in input_line_pointer into a floating point constant
2462 of type type, and store the appropriate bytes in *litP. The number
2463 of LITTLENUMS emitted is stored in *sizeP. An error message is
2464 returned, or NULL on OK. */
2467 md_atof (type, litP, sizeP)
2474 LITTLENUM_TYPE words[MAX_LITTLENUMS];
2475 LITTLENUM_TYPE *wordP;
2480 case 's': /* .single */
2486 case 'd': /* .double */
2488 case 'f': /* .float or .single */
2491 prec = 2; /* 1 32-bit word */
2494 case 'i': /* .ieee */
2498 type = 'f'; /* Rewrite type to be usable by atof_ieee() */
2501 case 'e': /* .ldouble */
2503 prec = 4; /* 2 32-bit words */
2509 return "Bad call to md_atof()";
2513 t = atof_ieee (input_line_pointer, type, words);
2515 t = c4x_atof (input_line_pointer, type, words);
2517 input_line_pointer = t;
2518 *sizeP = prec * sizeof (LITTLENUM_TYPE);
2520 /* This loops outputs the LITTLENUMs in REVERSE order; in accord with
2521 little endian byte order. */
2522 /* SES: However it is required to put the words (32-bits) out in the
2523 correct order, hence we write 2 and 2 littlenums in little endian
2524 order, while we keep the original order on successive words. */
2525 for(wordP = words; wordP<(words+prec) ; wordP+=2)
2527 if (wordP<(words+prec-1)) /* Dump wordP[1] (if we have one) */
2529 md_number_to_chars (litP, (valueT) (wordP[1]),
2530 sizeof (LITTLENUM_TYPE));
2531 litP += sizeof (LITTLENUM_TYPE);
2535 md_number_to_chars (litP, (valueT) (wordP[0]),
2536 sizeof (LITTLENUM_TYPE));
2537 litP += sizeof (LITTLENUM_TYPE);
2543 md_apply_fix3 (fixP, value, seg)
2546 segT seg ATTRIBUTE_UNUSED;
2548 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
2549 valueT val = *value;
2551 switch (fixP->fx_r_type)
2553 case BFD_RELOC_HI16:
2557 case BFD_RELOC_LO16:
2564 switch (fixP->fx_r_type)
2569 case BFD_RELOC_24_PCREL:
2572 case BFD_RELOC_16_PCREL:
2573 case BFD_RELOC_LO16:
2574 case BFD_RELOC_HI16:
2581 as_bad ("Bad relocation type: 0x%02x", fixP->fx_r_type);
2585 if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) fixP->fx_done = 1;
2588 /* Should never be called for c4x. */
2590 md_convert_frag (headers, sec, fragP)
2591 bfd *headers ATTRIBUTE_UNUSED;
2592 segT sec ATTRIBUTE_UNUSED;
2593 fragS *fragP ATTRIBUTE_UNUSED;
2595 as_fatal ("md_convert_frag");
2598 /* Should never be called for c4x. */
2600 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
2601 char *ptr ATTRIBUTE_UNUSED;
2602 addressT from_addr ATTRIBUTE_UNUSED;
2603 addressT to_addr ATTRIBUTE_UNUSED;
2604 fragS *frag ATTRIBUTE_UNUSED;
2605 symbolS *to_symbol ATTRIBUTE_UNUSED;
2607 as_fatal ("md_create_short_jmp\n");
2610 /* Should never be called for c4x. */
2612 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
2613 char *ptr ATTRIBUTE_UNUSED;
2614 addressT from_addr ATTRIBUTE_UNUSED;
2615 addressT to_addr ATTRIBUTE_UNUSED;
2616 fragS *frag ATTRIBUTE_UNUSED;
2617 symbolS *to_symbol ATTRIBUTE_UNUSED;
2619 as_fatal ("md_create_long_jump\n");
2622 /* Should never be called for c4x. */
2624 md_estimate_size_before_relax (fragP, segtype)
2625 register fragS *fragP ATTRIBUTE_UNUSED;
2626 segT segtype ATTRIBUTE_UNUSED;
2628 as_fatal ("md_estimate_size_before_relax\n");
2632 CONST char *md_shortopts = "bm:prs";
2633 struct option md_longopts[] =
2635 {NULL, no_argument, NULL, 0}
2638 size_t md_longopts_size = sizeof (md_longopts);
2641 md_parse_option (c, arg)
2647 case 'b': /* big model */
2650 case 'm': /* -m[c][34]x */
2651 if (tolower (*arg) == 'c')
2653 c4x_cpu = atoi (arg);
2654 if (!IS_CPU_C3X (c4x_cpu) && !IS_CPU_C4X (c4x_cpu))
2655 as_warn ("Unsupported processor generation %d\n", c4x_cpu);
2657 case 'p': /* push args */
2660 case 'r': /* register args */
2663 case 's': /* small model */
2674 md_show_usage (stream)
2679 -m30 | -m31 | -m32 | -m33 | -m40 | -m44\n\
2680 specify variant of architecture\n\
2681 -b big memory model\n\
2682 -p pass arguments on stack\n\
2683 -r pass arguments in registers (default)\n\
2684 -s small memory model (default)\n",
2688 /* This is called when a line is unrecognized. This is used to handle
2689 definitions of TI C3x tools style local labels $n where n is a single
2692 c4x_unrecognized_line (c)
2698 if (c != '$' || !isdigit (input_line_pointer[0]))
2701 s = input_line_pointer;
2703 /* Let's allow multiple digit local labels. */
2705 while (isdigit (*s))
2707 lab = lab * 10 + *s - '0';
2711 if (dollar_label_defined (lab))
2713 as_bad ("Label \"$%d\" redefined", lab);
2717 define_dollar_label (lab);
2718 colon (dollar_label_name (lab, 0));
2719 input_line_pointer = s + 1;
2724 /* Handle local labels peculiar to us referred to in an expression. */
2726 md_undefined_symbol (name)
2729 /* Look for local labels of the form $n. */
2730 if (name[0] == '$' && isdigit (name[1]))
2736 while (isdigit ((unsigned char) *s))
2738 lab = lab * 10 + *s - '0';
2741 if (dollar_label_defined (lab))
2743 name = dollar_label_name (lab, 0);
2744 symbolP = symbol_find (name);
2748 name = dollar_label_name (lab, 1);
2749 symbolP = symbol_find_or_make (name);
2757 /* Parse an operand that is machine-specific. */
2759 md_operand (expressionP)
2760 expressionS *expressionP ATTRIBUTE_UNUSED;
2764 /* Round up a section size to the appropriate boundary---do we need this? */
2766 md_section_align (segment, size)
2767 segT segment ATTRIBUTE_UNUSED;
2770 return size; /* Byte (i.e., 32-bit) alignment is fine? */
2777 /* Determine the PC offset for a C[34]x instruction.
2778 This could be simplified using some boolean algebra
2779 but at the expense of readability. */
2783 case 0x62: /* call (C4x) */
2784 case 0x64: /* rptb (C4x) */
2786 case 0x61: /* brd */
2787 case 0x63: /* laj */
2788 case 0x65: /* rptbd (C4x) */
2790 case 0x66: /* swi */
2797 switch ((op & 0xffe00000) >> 20)
2799 case 0x6a0: /* bB */
2800 case 0x720: /* callB */
2801 case 0x740: /* trapB */
2804 case 0x6a2: /* bBd */
2805 case 0x6a6: /* bBat */
2806 case 0x6aa: /* bBaf */
2807 case 0x722: /* lajB */
2808 case 0x748: /* latB */
2809 case 0x798: /* rptbd */
2816 switch ((op & 0xfe200000) >> 20)
2818 case 0x6e0: /* dbB */
2821 case 0x6e2: /* dbBd */
2831 /* Exactly what point is a PC-relative offset relative TO?
2832 With the C3x we have the following:
2833 DBcond, Bcond disp + PC + 1 => PC
2834 DBcondD, BcondD disp + PC + 3 => PC
2837 md_pcrel_from (fixP)
2840 unsigned char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
2843 op = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
2845 return ((fixP->fx_where + fixP->fx_frag->fr_address) >> 2) +
2849 /* Fill the alignment area with NOP's on .text, unless fill-data
2852 c4x_do_align (alignment, fill, len, max)
2853 int alignment ATTRIBUTE_UNUSED;
2854 const char *fill ATTRIBUTE_UNUSED;
2855 int len ATTRIBUTE_UNUSED;
2856 int max ATTRIBUTE_UNUSED;
2858 unsigned long nop = NOP_OPCODE;
2860 /* Because we are talking lwords, not bytes, adjust aligment to do words */
2863 if (alignment != 0 && !need_pass_2)
2867 /*if (subseg_text_p (now_seg))*/ /* FIXME: doesnt work for .text for some reason */
2868 frag_align_pattern( alignment, (const char *)&nop, sizeof(nop), max);
2871 frag_align (alignment, 0, max);*/
2874 frag_align (alignment, *fill, max);
2876 frag_align_pattern (alignment, fill, len, max);
2879 /* Return 1 to skip the default aligment function */
2883 /* Look for and remove parallel instruction operator ||. */
2887 char *s = input_line_pointer;
2891 /* If parallel instruction prefix found at start of line, skip it. */
2892 if (*input_line_pointer == '|' && input_line_pointer[1] == '|')
2897 input_line_pointer += 2;
2898 /* So line counters get bumped. */
2899 input_line_pointer[-1] = '\n';
2906 input_line_pointer = s;
2911 tc_gen_reloc (seg, fixP)
2912 asection *seg ATTRIBUTE_UNUSED;
2917 reloc = (arelent *) xmalloc (sizeof (arelent));
2919 reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
2920 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
2921 reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
2922 reloc->address /= OCTETS_PER_BYTE;
2923 reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
2924 if (reloc->howto == (reloc_howto_type *) NULL)
2926 as_bad_where (fixP->fx_file, fixP->fx_line,
2927 "reloc %d not supported by object file format",
2928 (int) fixP->fx_r_type);
2932 if (fixP->fx_r_type == BFD_RELOC_HI16)
2933 reloc->addend = fixP->fx_offset;
2935 reloc->addend = fixP->fx_addnumber;