#define MASK_CHAR ((int)(unsigned char)-1)
#endif
-#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
-/* This is the largest known floating point */
-/* format (for now). It will grow when we */
-/* do 4361 style flonums. */
+/* This is the largest known floating point format (for now). It will
+ grow when we do 4361 style flonums. */
+
+#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
/* Routines that read assembler source text to build spagetti in memory.
Another group of these functions is in the expr.c module. */
+/* for isdigit() */
#include <ctype.h>
#include "as.h"
+#ifdef BFD_ASSEMBLER
+#include "subsegs.h"
+#endif
#include "obstack.h"
#include "listing.h"
+
+#ifndef TC_START_LABEL
+#define TC_START_LABEL(x,y) (x==':')
+#endif
+
/* The NOP_OPCODE is for the alignment fill value.
* fill it a nop instruction so that the disassembler does not choke
* on it
_, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _, /* @abcdefghijklmno */
#endif
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
+#ifdef TC_HPPA
+ _,99, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* _!"#$%&'()*+,-./ */
+ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0123456789:;<=>? */
+#else
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, /* 0123456789:;<=>? */
+#endif
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
/* May point to (bignum_start-1). */
/* Never >= bignum_limit. */
-static char *old_buffer = 0; /* JF a hack */
+int target_big_endian;
+
+static char *old_buffer; /* JF a hack */
static char *old_input;
static char *old_limit;
#ifndef WORKING_DOT_WORD
struct broken_word *broken_words;
-int new_broken_words = 0;
+int new_broken_words;
#endif
static char *demand_copy_string PARAMS ((int *lenP));
static segT get_known_segmented_expression PARAMS ((expressionS * expP));
static void grow_bignum PARAMS ((void));
static void pobegin PARAMS ((void));
-void stringer PARAMS ((int append_zero));
extern int listing;
\f
\f
/* set up pseudo-op tables */
-struct hash_control *po_hash = NULL; /* use before set up: NULL->address error */
-
-#ifdef DONTDEF
-void s_gdbline (), s_gdblinetab ();
-void s_gdbbeg (), s_gdbblock (), s_gdbend (), s_gdbsym ();
-#endif
+struct hash_control *po_hash;
static const pseudo_typeS potable[] =
{
/* err */
/* extend */
{"extern", s_ignore, 0}, /* We treat all undef as ext */
- {"app-file", s_app_file, 0},
+ {"appfile", s_app_file, 1},
+ {"appline", s_app_line, 0},
{"file", s_app_file, 0},
{"fill", s_fill, 0},
{"float", float_cons, 'f'},
-#ifdef DONTDEF
- {"gdbbeg", s_gdbbeg, 0},
- {"gdbblock", s_gdbblock, 0},
- {"gdbend", s_gdbend, 0},
- {"gdbsym", s_gdbsym, 0},
- {"gdbline", s_gdbline, 0},
- {"gdblinetab", s_gdblinetab, 0},
-#endif
{"global", s_globl, 0},
{"globl", s_globl, 0},
{"hword", cons, 2},
register char c;
register char *s; /* string of symbol, '\0' appended */
register int temp;
- /* register struct frag * fragP; JF unused *//* a frag we just made */
pseudo_typeS *pop;
-#ifdef DONTDEF
- void gdb_block_beg ();
- void gdb_block_position ();
- void gdb_block_end ();
- void gdb_symbols_fixup ();
-#endif
buffer = input_scrub_new_file (name);
while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
{ /* We have another line to parse. */
know (buffer_limit[-1] == '\n'); /* Must have a sentinel. */
- contin: /* JF this goto is my fault I admit it. Someone brave please re-write
- the whole input section here? Pleeze??? */
+ contin: /* JF this goto is my fault I admit it.
+ Someone brave please re-write the whole
+ input section here? Pleeze??? */
while (input_line_pointer < buffer_limit)
- { /* We have more of this buffer to parse. */
+ {
+ /* We have more of this buffer to parse. */
/*
* We now have input_line_pointer->1st char of next line.
}
#endif
- } /* just passed a newline */
-
-
-
+ }
/*
* (And communicating via (linear) files is silly!
* If you must pass stuff, please pass a tree!)
*/
- if ((c = *input_line_pointer++) == '\t' || c == ' ' || c == '\f' || c == 0)
+ if ((c = *input_line_pointer++) == '\t'
+ || c == ' '
+ || c == '\f'
+ || c == 0)
{
c = *input_line_pointer++;
}
* [In case of pseudo-op, s->'.'.]
* Input_line_pointer->'\0' where c was.
*/
- if (c == ':')
+ if (TC_START_LABEL(c, input_line_pointer))
{
colon (s); /* user-defined label */
*input_line_pointer++ = ':'; /* Put ':' back for error messages' sake. */
}
else if (c == '=' || input_line_pointer[1] == '=')
- { /* JF deal with FOO=BAR */
+ {
equals (s);
demand_empty_rest_of_line ();
}
if (*s == '.')
{
/*
- * PSEUDO - OP.
- *
- * WARNING: c has next char, which may be end-of-line.
- * We lookup the pseudo-op table with s+1 because we
- * already know that the pseudo-op begins with a '.'.
- */
+ * PSEUDO - OP.
+ *
+ * WARNING: c has next char, which may be end-of-line.
+ * We lookup the pseudo-op table with s+1 because we
+ * already know that the pseudo-op begins with a '.'.
+ */
pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
/* Put it back for error messages etc. */
*input_line_pointer = c;
- /* The following skip of whitespace is compulsory. */
- /* A well shaped space is sometimes all that separates keyword from operands. */
+ /* The following skip of whitespace is compulsory.
+ A well shaped space is sometimes all that separates
+ keyword from operands. */
if (c == ' ' || c == '\t')
{
input_line_pointer++;
} /* Skip seperator after keyword. */
/*
- * Input_line is restored.
- * Input_line_pointer->1st non-blank char
- * after pseudo-operation.
- */
+ * Input_line is restored.
+ * Input_line_pointer->1st non-blank char
+ * after pseudo-operation.
+ */
if (!pop)
{
ignore_rest_of_line ();
input_line_pointer++;
temp_fill = get_absolute_expression ();
}
- else if (now_seg != SEG_DATA && now_seg != SEG_BSS)
+ else if (now_seg != data_section && now_seg != bss_section)
temp_fill = NOP_OPCODE;
else
temp_fill = 0;
if (temp && !need_pass_2)
frag_align (temp, (int) temp_fill);
+ record_alignment (now_seg, temp);
+
demand_empty_rest_of_line ();
} /* s_align_bytes() */
input_line_pointer++;
temp_fill = get_absolute_expression ();
}
- else if (now_seg != SEG_DATA && now_seg != SEG_BSS)
+ /* @@ Fix this right for BFD! */
+ else if (now_seg != data_section && now_seg != bss_section)
temp_fill = NOP_OPCODE;
else
temp_fill = 0;
register char *name;
register char c;
register char *p;
- register int temp;
+ valueT temp;
register symbolS *symbolP;
name = input_line_pointer;
S_SET_VALUE (symbolP, temp);
S_SET_EXTERNAL (symbolP);
}
-#ifdef VMS
- if (!temp)
- symbolP->sy_other = const_flag;
-#endif
+#ifdef OBJ_VMS
+ if ( (!temp) || !flagseen['1'])
+ S_GET_OTHER(symbolP) = const_flag;
+#endif /* not OBJ_VMS */
know (symbolP->sy_frag == &zero_address_frag);
demand_empty_rest_of_line ();
} /* s_comm() */
register int temp;
temp = get_absolute_expression ();
-#ifdef MANY_SEGMENTS
- subseg_new (SEG_E1, (subsegT) temp);
+#ifdef BFD_ASSEMBLER
+ subseg_set (data_section, (subsegT) temp);
#else
- subseg_new (SEG_DATA, (subsegT) temp);
+ subseg_new (data_section, (subsegT) temp);
#endif
-#ifdef VMS
+#ifdef OBJ_VMS
const_flag = 0;
#endif
demand_empty_rest_of_line ();
}
+/* Handle the .appfile pseudo-op. This is automatically generated by
+ do_scrub_next_char when a preprocessor # line comment is seen with
+ a file name. This default definition may be overridden by the
+ object or CPU specific pseudo-ops. This function is also the
+ default definition for .file; the APPFILE argument is 1 for
+ .appfile, 0 for .file. */
+
void
-s_app_file ()
+s_app_file (appfile)
+ int appfile;
{
register char *s;
int length;
/* Some assemblers tolerate immediately following '"' */
if ((s = demand_copy_string (&length)) != 0)
{
- new_logical_line (s, -1);
+ /* If this is a fake .appfile, a fake newline was inserted into
+ the buffer. Passing -2 to new_logical_line tells it to
+ account for it. */
+ new_logical_line (s, appfile ? -2 : -1);
demand_empty_rest_of_line ();
+#ifdef LISTING
+ if (listing)
+ listing_source_file (s);
+#endif
}
#ifdef OBJ_COFF
c_dot_file_symbol (s);
#endif /* OBJ_COFF */
-} /* s_app_file() */
+#ifdef OBJ_ELF
+ elf_file_symbol (s);
+#endif
+}
+
+/* Handle the .appline pseudo-op. This is automatically generated by
+ do_scrub_next_char when a preprocessor # line comment is seen.
+ This default definition may be overridden by the object or CPU
+ specific pseudo-ops. */
+
+void
+s_app_line ()
+{
+ int l;
+
+ /* The given number is that of the next line. */
+ l = get_absolute_expression () - 1;
+ new_logical_line ((char *) NULL, l);
+#ifdef LISTING
+ if (listing)
+ listing_source_line (l);
+#endif
+ demand_empty_rest_of_line ();
+}
void
s_fill ()
temp_fill = get_absolute_expression ();
}
}
- /*
- * This is to be compatible with BSD 4.2 AS, not for any rational reason.
- */
+ /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
#define BSD_FILL_SIZE_CROCK_8 (8)
if (temp_size > BSD_FILL_SIZE_CROCK_8)
{
if (temp_size && !need_pass_2)
{
p = frag_var (rs_fill, (int) temp_size, (int) temp_size, (relax_substateT) 0, (symbolS *) 0, temp_repeat, (char *) 0);
- bzero (p, (int) temp_size);
- /*
- * The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX flavoured AS.
- * The following bizzare behaviour is to be compatible with above.
- * I guess they tried to take up to 8 bytes from a 4-byte expression
- * and they forgot to sign extend. Un*x Sux.
- */
+ memset (p, 0, (int) temp_size);
+ /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
+ * flavoured AS. The following bizzare behaviour is to be
+ * compatible with above. I guess they tried to take up to 8
+ * bytes from a 4-byte expression and they forgot to sign
+ * extend. Un*x Sux. */
#define BSD_FILL_SIZE_CROCK_4 (4)
- md_number_to_chars (p, temp_fill, temp_size > BSD_FILL_SIZE_CROCK_4 ? BSD_FILL_SIZE_CROCK_4 : (int) temp_size);
- /*
- * Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
- * but emits no error message because it seems a legal thing to do.
- * It is a degenerate case of .fill but could be emitted by a compiler.
- */
- }
- demand_empty_rest_of_line ();
-}
-
-#ifdef DONTDEF
-void
-s_gdbbeg ()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- if (temp < 0)
- as_warn ("Block number <0. Ignored.");
- else if (flagseen['G'])
- gdb_block_beg ((long) temp, frag_now, (long) (obstack_next_free (&frags) - frag_now->fr_literal));
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbblock ()
-{
- register int position;
- int temp;
-
- if (get_absolute_expression_and_terminator (&temp) != ',')
- {
- as_bad ("expected comma before position in .gdbblock");
- --input_line_pointer;
- ignore_rest_of_line ();
- return;
- }
- position = get_absolute_expression ();
- if (flagseen['G'])
- gdb_block_position ((long) temp, (long) position);
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbend ()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- if (temp < 0)
- as_warn ("Block number <0. Ignored.");
- else if (flagseen['G'])
- gdb_block_end ((long) temp, frag_now, (long) (obstack_next_free (&frags) - frag_now->fr_literal));
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbsym ()
-{
- register char *name, *p;
- register char c;
- register symbolS *symbolP;
- register int temp;
-
- name = input_line_pointer;
- c = get_symbol_end ();
- p = input_line_pointer;
- symbolP = symbol_find_or_make (name);
- *p = c;
- SKIP_WHITESPACE ();
- if (*input_line_pointer != ',')
- {
- as_bad ("Expected comma after name");
- ignore_rest_of_line ();
- return;
- }
- input_line_pointer++;
- if ((temp = get_absolute_expression ()) < 0)
- {
- as_bad ("Bad GDB symbol file offset (%d.) <0! Ignored.", temp);
- ignore_rest_of_line ();
- return;
- }
- if (flagseen['G'])
- gdb_symbols_fixup (symbolP, (long) temp);
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbline ()
-{
- int file_number, lineno;
-
- if (get_absolute_expression_and_terminator (&file_number) != ',')
- {
- as_bad ("expected comman after filenum in .gdbline");
- ignore_rest_of_line ();
- return;
- }
- lineno = get_absolute_expression ();
- if (flagseen['G'])
- gdb_line (file_number, lineno);
- demand_empty_rest_of_line ();
-}
-
-
-void
-s_gdblinetab ()
-{
- int file_number, offset;
-
- if (get_absolute_expression_and_terminator (&file_number) != ',')
- {
- as_bad ("expected comma after filenum in .gdblinetab");
- ignore_rest_of_line ();
- return;
+ md_number_to_chars (p, temp_fill,
+ (temp_size > BSD_FILL_SIZE_CROCK_4
+ ? BSD_FILL_SIZE_CROCK_4
+ : (int) temp_size));
+ /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
+ * but emits no error message because it seems a legal thing to do.
+ * It is a degenerate case of .fill but could be emitted by a compiler.
+ */
}
- offset = get_absolute_expression ();
- if (flagseen['G'])
- gdb_line_tab (file_number, offset);
demand_empty_rest_of_line ();
}
-#endif
-
void
s_globl ()
{
- register char *name;
- register int c;
- register symbolS *symbolP;
+ char *name;
+ int c;
+ symbolS *symbolP;
do
{
}
while (c == ',');
demand_empty_rest_of_line ();
-} /* s_globl() */
+}
void
s_lcomm (needs_align)
- int needs_align; /* 1 if this was a ".bss" directive, which may require
- * a 3rd argument (alignment).
- * 0 if it was an ".lcomm" (2 args only)
- */
+ /* 1 if this was a ".bss" directive, which may require a 3rd argument
+ (alignment); 0 if it was an ".lcomm" (2 args only) */
+ int needs_align;
{
register char *name;
register char c;
register char *p;
register int temp;
register symbolS *symbolP;
+ segT current_seg = now_seg;
+ subsegT current_subseg = now_subseg;
const int max_alignment = 15;
int align = 0;
+ segT bss_seg = bss_section;
name = input_line_pointer;
c = get_symbol_end ();
return;
}
+#ifdef TC_MIPS
+#ifdef OBJ_ECOFF
+ /* For MIPS ECOFF, small objects are put in .sbss. */
+ if (temp <= bfd_get_gp_size (stdoutput))
+ bss_seg = subseg_new (".sbss", 1);
+#endif
+#endif
+
if (needs_align)
{
align = 0;
align = 0;
as_warn ("Alignment negative. 0 assumed.");
}
-#ifdef MANY_SEGMENTS
-#define SEG_BSS SEG_E2
- record_alignment (SEG_E2, align);
-#else
- record_alignment (SEG_BSS, align);
-#endif
+ record_alignment (bss_seg, align);
} /* if needs align */
*p = 0;
S_GET_OTHER (symbolP) == 0 &&
S_GET_DESC (symbolP) == 0 &&
#endif /* OBJ_AOUT or OBJ_BOUT */
- (S_GET_SEGMENT (symbolP) == SEG_BSS
+ (S_GET_SEGMENT (symbolP) == bss_seg
|| (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
{
char *p;
- segT current_seg = now_seg;
- subsegT current_subseg = now_subseg;
- subseg_new (SEG_BSS, 1);
+#ifdef BFD_ASSEMBLER
+ subseg_set (bss_seg, 1);
+#else
+ subseg_new (bss_seg, 1);
+#endif
if (align)
frag_align (align, 0);
/* detach from old frag */
- if (S_GET_SEGMENT (symbolP) == SEG_BSS)
+ if (S_GET_SEGMENT (symbolP) == bss_seg)
symbolP->sy_frag->fr_symbol = NULL;
symbolP->sy_frag = frag_now;
temp, (char *)0);
*p = 0;
- S_SET_SEGMENT (symbolP, SEG_BSS);
+ S_SET_SEGMENT (symbolP, bss_seg);
#ifdef OBJ_COFF
/* The symbol may already have been created with a preceding
- * ".globl" directive -- be careful not to step on storage
- * class in that case. Otherwise, set it to static.
- */
+ ".globl" directive -- be careful not to step on storage class
+ in that case. Otherwise, set it to static. */
if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
{
S_SET_STORAGE_CLASS (symbolP, C_STAT);
}
#endif /* OBJ_COFF */
- subseg_new (current_seg, current_subseg);
}
else
{
as_bad ("Ignoring attempt to re-define symbol %s.", name);
}
- demand_empty_rest_of_line ();
- return;
+#ifdef BFD_ASSEMBLER
+ subseg_set (current_seg, current_subseg);
+#else
+ subseg_new (current_seg, current_subseg);
+#endif
+
+ demand_empty_rest_of_line ();
} /* s_lcomm() */
void
}
input_line_pointer++;
segment = expression (&exp);
- if (segment != SEG_ABSOLUTE
-#ifdef MANY_SEGMENTS
- && !(segment >= SEG_E0 && segment <= SEG_UNKNOWN)
-#else
- && segment != SEG_DATA
- && segment != SEG_TEXT
- && segment != SEG_BSS
-#endif
- && segment != SEG_REGISTER)
+ if (segment != absolute_section
+ && segment != reg_section
+ && ! SEG_NORMAL (segment))
{
as_bad ("Bad expression: %s", segment_name (segment));
ignore_rest_of_line ();
*p = 0;
symbolP = symbol_find_or_make (name);
- /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0
- && symbolP->sy_desc == 0) out of this test
- because coff doesn't have those fields, and I
- can't see when they'd ever be tripped. I don't
- think I understand why they were here so I may
- have introduced a bug. As recently as 1.37 didn't
- have this test anyway. xoxorich. */
+ /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
+ symbolP->sy_desc == 0) out of this test because coff doesn't have
+ those fields, and I can't see when they'd ever be tripped. I
+ don't think I understand why they were here so I may have
+ introduced a bug. As recently as 1.37 didn't have this test
+ anyway. xoxorich. */
- if (S_GET_SEGMENT (symbolP) == SEG_UNKNOWN
+ if (S_GET_SEGMENT (symbolP) == undefined_section
&& S_GET_VALUE (symbolP) == 0)
{
- /* The name might be an undefined .global symbol; be
- sure to keep the "external" bit. */
+ /* The name might be an undefined .global symbol; be sure to
+ keep the "external" bit. */
S_SET_SEGMENT (symbolP, segment);
S_SET_VALUE (symbolP, (valueT) (exp.X_add_number));
}
expressionS exp;
register long temp_fill;
register char *p;
- /*
- * Don't believe the documentation of BSD 4.2 AS.
- * There is no such thing as a sub-segment-relative origin.
- * Any absolute origin is given a warning, then assumed to be segment-relative.
- * Any segmented origin expression ("foo+42") had better be in the right
- * segment or the .org is ignored.
- *
- * BSD 4.2 AS warns if you try to .org backwards. We cannot because we
- * never know sub-segment sizes when we are reading code.
- * BSD will crash trying to emit -ve numbers of filler bytes in certain
- * .orgs. We don't crash, but see as-write for that code.
- */
- /*
- * Don't make frag if need_pass_2==1.
- */
+ /* Don't believe the documentation of BSD 4.2 AS. There is no such
+ thing as a sub-segment-relative origin. Any absolute origin is
+ given a warning, then assumed to be segment-relative. Any
+ segmented origin expression ("foo+42") had better be in the right
+ segment or the .org is ignored.
+
+ BSD 4.2 AS warns if you try to .org backwards. We cannot because
+ we never know sub-segment sizes when we are reading code. BSD
+ will crash trying to emit negative numbers of filler bytes in
+ certain .orgs. We don't crash, but see as-write for that code.
+
+ Don't make frag if need_pass_2==1. */
segment = get_known_segmented_expression (&exp);
if (*input_line_pointer == ',')
{
temp_fill = 0;
if (!need_pass_2)
{
- if (segment != now_seg && segment != SEG_ABSOLUTE)
+ if (segment != now_seg && segment != absolute_section)
as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
segment_name (segment), segment_name (now_seg));
p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp.X_add_symbol,
register symbolS *symbolP;
/*
- * Especial apologies for the random logic:
- * this just grew, and could be parsed much more simply!
- * Dean in haste.
- */
+ * Especial apologies for the random logic:
+ * this just grew, and could be parsed much more simply!
+ * Dean in haste.
+ */
name = input_line_pointer;
delim = get_symbol_end ();
end_name = input_line_pointer;
if (!need_pass_2)
{
- if (segment != now_seg && segment != SEG_ABSOLUTE)
+ if (segment != now_seg && segment != absolute_section)
as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
segment_name (segment),
segment_name (now_seg));
if ((symbolP = symbol_find (name)) == NULL
&& (symbolP = md_undefined_symbol (name)) == NULL)
{
- symbolP = symbol_new (name,
- SEG_UNKNOWN,
- 0,
- &zero_address_frag);
+ symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
#ifdef OBJ_COFF
/* "set" symbols are local unless otherwise specified. */
SF_SET_LOCAL (symbolP);
}
if (mult)
{
- temp_fill *= mult;
+ temp_repeat *= mult;
}
if (temp_repeat <= 0)
{
register int temp;
temp = get_absolute_expression ();
-#ifdef MANY_SEGMENTS
- subseg_new (SEG_E0, (subsegT) temp);
+#ifdef BFD_ASSEMBLER
+ subseg_set (text_section, (subsegT) temp);
#else
- subseg_new (SEG_TEXT, (subsegT) temp);
+ subseg_new (text_section, (subsegT) temp);
#endif
demand_empty_rest_of_line ();
} /* s_text() */
\f
-/*(JF was static, but can't be if machine dependent pseudo-ops are to use it */
-
void
demand_empty_rest_of_line ()
{
know (symbolP); /* NULL pointer is logic error. */
#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
+ /* @@ Fix this right for BFD. */
ext = S_IS_EXTERNAL (symbolP);
#endif /* OBJ_AOUT or OBJ_BOUT */
- if ((segment = expression (&exp)) == SEG_ABSENT)
+ if ((segment = expression (&exp)) == absent_section)
{
as_bad ("Missing expression: absolute 0 assumed");
- exp.X_seg = SEG_ABSOLUTE;
+ exp.X_seg = absolute_section;
exp.X_add_number = 0;
}
- switch (segment)
+ if (segment == reg_section)
{
- case SEG_REGISTER:
- S_SET_SEGMENT (symbolP, SEG_REGISTER);
+ S_SET_SEGMENT (symbolP, reg_section);
S_SET_VALUE (symbolP, exp.X_add_number);
symbolP->sy_frag = &zero_address_frag;
- break;
-
- case SEG_BIG:
+ }
+ else if (segment == big_section)
+ {
as_bad ("%s number invalid. Absolute 0 assumed.",
exp.X_add_number > 0 ? "Bignum" : "Floating-Point");
- S_SET_SEGMENT (symbolP, SEG_ABSOLUTE);
+ S_SET_SEGMENT (symbolP, absolute_section);
#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
+ /* @@ Fix this right for BFD. */
ext ? S_SET_EXTERNAL (symbolP) :
S_CLEAR_EXTERNAL (symbolP);
#endif /* OBJ_AOUT or OBJ_BOUT */
S_SET_VALUE (symbolP, 0);
symbolP->sy_frag = &zero_address_frag;
- break;
-
- case SEG_ABSENT:
+ }
+ else if (segment == absent_section)
+ {
as_warn ("No expression: Using absolute 0");
- S_SET_SEGMENT (symbolP, SEG_ABSOLUTE);
+ S_SET_SEGMENT (symbolP, absolute_section);
#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
+ /* @@ Fix this right for BFD. */
ext ? S_SET_EXTERNAL (symbolP) :
S_CLEAR_EXTERNAL (symbolP);
#endif /* OBJ_AOUT or OBJ_BOUT */
S_SET_VALUE (symbolP, 0);
symbolP->sy_frag = &zero_address_frag;
- break;
-
- case SEG_DIFFERENCE:
+ }
+ else if (segment == diff_section)
+ {
if (exp.X_add_symbol && exp.X_subtract_symbol
&& (S_GET_SEGMENT (exp.X_add_symbol) ==
S_GET_SEGMENT (exp.X_subtract_symbol)))
{
- if (exp.X_add_symbol->sy_frag != exp.X_subtract_symbol->sy_frag)
+ if (exp.X_add_symbol->sy_frag == exp.X_subtract_symbol->sy_frag)
{
- as_bad ("Unknown expression: symbols %s and %s are in different frags.",
- S_GET_NAME (exp.X_add_symbol), S_GET_NAME (exp.X_subtract_symbol));
- need_pass_2++;
+ exp.X_add_number += S_GET_VALUE (exp.X_add_symbol) -
+ S_GET_VALUE (exp.X_subtract_symbol);
+ goto abs;
}
- exp.X_add_number += S_GET_VALUE (exp.X_add_symbol) -
- S_GET_VALUE (exp.X_subtract_symbol);
+ as_bad ("Invalid expression: separation between symbols `%s'",
+ S_GET_NAME (exp.X_add_symbol));
+ as_bad (" and `%s' may not be constant",
+ S_GET_NAME (exp.X_subtract_symbol));
+ need_pass_2++;
}
else
- as_bad ("Complex expression. Absolute segment assumed.");
- case SEG_ABSOLUTE:
- S_SET_SEGMENT (symbolP, SEG_ABSOLUTE);
+ {
+ as_bad ("Complex expression. Absolute segment assumed.");
+ goto abs;
+ }
+ }
+ else if (segment == absolute_section)
+ {
+ abs:
+ S_SET_SEGMENT (symbolP, absolute_section);
#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
+ /* @@ Fix this right for BFD. */
ext ? S_SET_EXTERNAL (symbolP) :
S_CLEAR_EXTERNAL (symbolP);
#endif /* OBJ_AOUT or OBJ_BOUT */
S_SET_VALUE (symbolP, exp.X_add_number);
symbolP->sy_frag = &zero_address_frag;
- break;
-
- default:
-#ifdef MANY_SEGMENTS
- S_SET_SEGMENT (symbolP, segment);
-#else
+ }
+ else if (segment == pass1_section)
+ {
+ symbolP->sy_value.X_add_symbol = exp.X_add_symbol;
+ symbolP->sy_value.X_subtract_symbol = NULL;
+ symbolP->sy_value.X_add_number = 0;
+ symbolP->sy_value.X_seg = undefined_section;
+ as_bad ("Unknown expression");
+ know (need_pass_2 == 1);
+ }
+ else if (segment == undefined_section)
+ {
+ symbolP->sy_value.X_add_symbol = exp.X_add_symbol;
+ symbolP->sy_value.X_subtract_symbol = NULL;
+ symbolP->sy_value.X_add_number = 0;
+ symbolP->sy_value.X_seg = undefined_section;
+ }
+ else
+ {
+#ifndef BFD_ASSEMBLER
+#ifndef MANY_SEGMENTS
switch (segment)
{
case SEG_DATA:
- S_SET_SEGMENT (symbolP, SEG_DATA);
- break;
case SEG_TEXT:
- S_SET_SEGMENT (symbolP, SEG_TEXT);
- break;
case SEG_BSS:
- S_SET_SEGMENT (symbolP, SEG_BSS);
break;
default:
as_fatal ("failed sanity check.");
} /* switch on segment */
#endif
+#endif
+ S_SET_SEGMENT (symbolP, segment);
#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
+ /* @@ Fix this right for BFD! */
if (ext)
{
S_SET_EXTERNAL (symbolP);
S_SET_VALUE (symbolP, exp.X_add_number + S_GET_VALUE (exp.X_add_symbol));
symbolP->sy_frag = exp.X_add_symbol->sy_frag;
- break;
-
- case SEG_PASS1: /* Not an error. Just try another pass. */
- symbolP->sy_forward = exp.X_add_symbol;
- as_bad ("Unknown expression");
- know (need_pass_2 == 1);
- break;
-
- case SEG_UNKNOWN:
- symbolP->sy_forward = exp.X_add_symbol;
- /* as_warn("unknown symbol"); */
- /* need_pass_2 = 1; */
- break;
-
-
-
}
}
\f
* in the case of a long. Not worth the crocks required to fix it.
*/
+/* Select a parser for cons expressions. */
+
+/* Some targets need to parse the expression in various fancy ways.
+ You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
+ (for example, the HPPA does this). Otherwise, you can define
+ BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
+ REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
+ are defined, which is the normal case, then only simple expressions
+ are permitted. */
+
+#ifndef TC_PARSE_CONS_EXPRESSION
+#ifdef BITFIELD_CONS_EXPRESSIONS
+#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
+static void
+parse_bitfield_cons PARAMS ((expressionS *exp, unsigned int nbytes));
+#endif
+#ifdef MRI
+#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_mri_cons (EXP)
+static void
+parse_mri_cons PARAMS ((expressionS *exp));
+#endif
+#ifdef REPEAT_CONS_EXPRESSIONS
+#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
+static void
+parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes));
+#endif
+
+/* If we haven't gotten one yet, just call expression. */
+#ifndef TC_PARSE_CONS_EXPRESSION
+#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
+#endif
+#endif
+
/* worker to do .byte etc statements */
/* clobbers input_line_pointer, checks */
/* end-of-line. */
cons (nbytes)
register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */
{
- register char c;
- register long mask; /* High-order bits we will left-truncate, */
- /* but includes sign bit also. */
- register long get; /* what we get */
- register long use; /* get after truncation. */
- register long unmask; /* what bits we will store */
- register char *p;
- register segT segment;
expressionS exp;
- /*
- * Input_line_pointer->1st char after pseudo-op-code and could legally
- * be a end-of-line. (Or, less legally an eof - which we cope with.)
- */
- /* JF << of >= number of bits in the object is undefined. In particular
- SPARC (Sun 4) has problems */
+ if (is_it_end_of_statement ())
+ {
+ demand_empty_rest_of_line ();
+ return;
+ }
- if (nbytes >= sizeof (long))
+ do
{
- mask = 0;
+ TC_PARSE_CONS_EXPRESSION (&exp, nbytes);
+ emit_expr (&exp, nbytes);
}
- else
+ while (*input_line_pointer++ == ',');
+
+ input_line_pointer--; /* Put terminator back into stream. */
+ demand_empty_rest_of_line ();
+} /* cons() */
+
+/* Put the contents of expression EXP into the object file using
+ NBYTES bytes. If need_pass_2 is 1, this does nothing. */
+
+void
+emit_expr (exp, nbytes)
+ expressionS *exp;
+ unsigned int nbytes;
+{
+ segT segment;
+ register char *p;
+
+ /* Don't do anything if we are going to make another pass. */
+ if (need_pass_2)
+ return;
+
+ segment = exp->X_seg;
+
+ /* Don't call this if we are going to junk this pass anyway! */
+ know (segment != pass1_section);
+
+ if (segment == diff_section && exp->X_add_symbol == NULL)
+ {
+ as_bad ("Subtracting symbol \"%s\" (segment \"%s\") is too hard. Absolute segment assumed.",
+ S_GET_NAME (exp->X_subtract_symbol),
+ segment_name (S_GET_SEGMENT (exp->X_subtract_symbol)));
+ segment = absolute_section;
+ /* Leave exp->X_add_number alone. */
+ }
+ else if (segment == absent_section)
+ {
+ as_warn ("0 assumed for missing expression");
+ exp->X_add_number = 0;
+ know (exp->X_add_symbol == NULL);
+ segment = absolute_section;
+ }
+ else if (segment == big_section)
{
- mask = ~0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */
- } /* bigger than a long */
+ as_bad ("%s number invalid. Absolute 0 assumed.",
+ exp->X_add_number > 0 ? "Bignum" : "Floating-Point");
+ exp->X_add_number = 0;
+ segment = absolute_section;
+ }
- unmask = ~mask; /* Do store these bits. */
+ p = frag_more (nbytes);
-#ifdef NEVER
- "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
- mask = ~(unmask >> 1); /* Includes sign bit now. */
+#ifndef WORKING_DOT_WORD
+ /* If we have the difference of two symbols in a word, save it on
+ the broken_words list. See the code in write.c. */
+ if (segment == diff_section && nbytes == 2)
+ {
+ struct broken_word *x;
+
+ x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
+ x->next_broken_word = broken_words;
+ broken_words = x;
+ x->frag = frag_now;
+ x->word_goes_here = p;
+ x->dispfrag = 0;
+ x->add = exp->X_add_symbol;
+ x->sub = exp->X_subtract_symbol;
+ x->addnum = exp->X_add_number;
+ x->added = 0;
+ new_broken_words++;
+ return;
+ }
#endif
- /*
- * The following awkward logic is to parse ZERO or more expressions,
- * comma seperated. Recall an expression includes its leading &
- * trailing blanks. We fake a leading ',' if there is (supposed to
- * be) a 1st expression, and keep demanding 1 expression for each ','.
- */
- if (is_it_end_of_statement ())
+ if (segment == absolute_section)
{
- c = 0; /* Skip loop. */
- input_line_pointer++; /* Matches end-of-loop 'correction'. */
+ register long get;
+ register long use;
+ register long mask;
+ register long unmask;
+
+ /* JF << of >= number of bits in the object is undefined. In
+ particular SPARC (Sun 4) has problems */
+ if (nbytes >= sizeof (long))
+ mask = 0;
+ else
+ mask = ~0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */
+
+ unmask = ~mask; /* Do store these bits. */
+
+#ifdef NEVER
+ "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
+ mask = ~(unmask >> 1); /* Includes sign bit now. */
+#endif
+
+ get = exp->X_add_number;
+ use = get & unmask;
+ if ((get & mask) != 0 && (get & mask) != mask)
+ { /* Leading bits contain both 0s & 1s. */
+ as_warn ("Value 0x%x truncated to 0x%x.", get, use);
+ }
+ md_number_to_chars (p, use, nbytes); /* put bytes in right order. */
}
else
{
- c = ',';
- } /* if the end else fake it */
+ md_number_to_chars (p, (long) 0, nbytes);
+
+ /* Now we need to generate a fixS to record the symbol value.
+ This is easy for BFD. For other targets it can be more
+ complex. For very complex cases (currently, the HPPA and
+ NS32K), you can define TC_CONS_FIX_NEW to do whatever you
+ want. For simpler cases, you can define TC_CONS_RELOC to be
+ the name of the reloc code that should be stored in the fixS.
+ If neither is defined, the code uses NO_RELOC if it is
+ defined, and otherwise uses 0. */
+
+#ifdef BFD_ASSEMBLER
+ fix_new (frag_now, p - frag_now->fr_literal, nbytes,
+ exp->X_add_symbol, exp->X_subtract_symbol,
+ exp->X_add_number, 0,
+ /* @@ Should look at CPU word size. */
+ BFD_RELOC_32);
+#else
+#ifdef TC_CONS_FIX_NEW
+ TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
+#else
+ /* Figure out which reloc number to use. Use TC_CONS_RELOC if
+ it is defined, otherwise use NO_RELOC if it is defined,
+ otherwise use 0. */
+#ifndef TC_CONS_RELOC
+#ifdef NO_RELOC
+#define TC_CONS_RELOC NO_RELOC
+#else
+#define TC_CONS_RELOC 0
+#endif
+#endif
+ fix_new (frag_now, p - frag_now->fr_literal, nbytes,
+ exp->X_add_symbol, exp->X_subtract_symbol,
+ exp->X_add_number, 0, TC_CONS_RELOC);
+#endif /* TC_CONS_FIX_NEW */
+#endif /* BFD_ASSEMBLER */
+ }
+}
+\f
+#ifdef BITFIELD_CONS_EXPRESSIONS
- /* Do loop. */
- while (c == ',')
- {
-#ifdef WANT_BITFIELDS
- unsigned int bits_available = BITS_PER_CHAR * nbytes;
- /* used for error messages and rescanning */
- char *hold = input_line_pointer;
-#endif /* WANT_BITFIELDS */
-#ifdef MRI
- if (*input_line_pointer == '\'')
+/* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
+ w:x,y:z, where w and y are bitwidths and x and y are values. They
+ then pack them all together. We do a little better in that we allow
+ them in words, longs, etc. and we'll pack them in target byte order
+ for you.
+
+ The rules are: pack least significat bit first, if a field doesn't
+ entirely fit, put it in the next unit. Overflowing the bitfield is
+ explicitly *not* even a warning. The bitwidth should be considered
+ a "mask".
+
+ To use this function the tc-XXX.h file should define
+ BITFIELD_CONS_EXPRESSIONS. */
+
+static void
+parse_bitfield_cons (exp, nbytes)
+ expressionS *exp;
+ unsigned int nbytes;
+{
+ unsigned int bits_available = BITS_PER_CHAR * nbytes;
+ char *hold = input_line_pointer;
+ segT segment;
+
+ segment = expression (exp);
+
+ if (*input_line_pointer == ':')
+ { /* bitfields */
+ long value = 0;
+
+ for (;;)
{
- /* An MRI style string, cut into as many bytes as will fit
- into a nbyte chunk, left justify if necessary, and sepatate
- with commas so we can try again later */
- int scan = 0;
- unsigned int result = 0;
- input_line_pointer++;
- for (scan = 0; scan < nbytes; scan++)
+ unsigned long width;
+
+ if (*input_line_pointer != ':')
{
- if (*input_line_pointer == '\'')
- {
- if (input_line_pointer[1] == '\'')
- {
- input_line_pointer++;
- }
- else
- break;
- }
- result = (result << 8) | (*input_line_pointer++);
- }
+ input_line_pointer = hold;
+ break;
+ } /* next piece is not a bitfield */
+
+ /* In the general case, we can't allow
+ full expressions with symbol
+ differences and such. The relocation
+ entries for symbols not defined in this
+ assembly would require arbitrary field
+ widths, positions, and masks which most
+ of our current object formats don't
+ support.
+
+ In the specific case where a symbol
+ *is* defined in this assembly, we
+ *could* build fixups and track it, but
+ this could lead to confusion for the
+ backends. I'm lazy. I'll take any
+ SEG_ABSOLUTE. I think that means that
+ you can use a previous .set or
+ .equ type symbol. xoxorich. */
+
+ if (segment == absent_section)
+ {
+ as_warn ("Using a bit field width of zero.");
+ exp->X_add_number = 0;
+ segment = absolute_section;
+ } /* implied zero width bitfield */
- /* Left justify */
- while (scan < nbytes)
+ if (segment != absolute_section)
{
- result <<= 8;
- scan++;
- }
- /* Create correct expression */
- exp.X_add_symbol = 0;
- exp.X_add_number = result;
- exp.X_seg = segment = SEG_ABSOLUTE;
- /* Fake it so that we can read the next char too */
- if (input_line_pointer[0] != '\'' ||
- (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
+ *input_line_pointer = '\0';
+ as_bad ("Field width \"%s\" too complex for a bitfield.\n", hold);
+ *input_line_pointer = ':';
+ demand_empty_rest_of_line ();
+ return;
+ } /* too complex */
+
+ if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes))
{
- input_line_pointer -= 2;
- input_line_pointer[0] = ',';
- input_line_pointer[1] = '\'';
- }
- else
- input_line_pointer++;
+ as_warn ("Field width %d too big to fit in %d bytes: truncated to %d bits.",
+ width, nbytes, (BITS_PER_CHAR * nbytes));
+ width = BITS_PER_CHAR * nbytes;
+ } /* too big */
- }
- else
-#endif
- /* At least scan over the expression. */
- segment = expression (&exp);
-
-#ifdef WANT_BITFIELDS
- /* Some other assemblers, (eg, asm960), allow
- bitfields after ".byte" as w:x,y:z, where w and
- y are bitwidths and x and y are values. They
- then pack them all together. We do a little
- better in that we allow them in words, longs,
- etc. and we'll pack them in target byte order
- for you.
-
- The rules are: pack least significat bit first,
- if a field doesn't entirely fit, put it in the
- next unit. Overflowing the bitfield is
- explicitly *not* even a warning. The bitwidth
- should be considered a "mask".
-
- FIXME-SOMEDAY: If this is considered generally
- useful, this logic should probably be reworked.
- xoxorich. */
-
- if (*input_line_pointer == ':')
- { /* bitfields */
- long value = 0;
-
- for (;;)
+ if (width > bits_available)
{
- unsigned long width;
+ /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
+ input_line_pointer = hold;
+ exp->X_add_number = value;
+ break;
+ } /* won't fit */
- if (*input_line_pointer != ':')
- {
- input_line_pointer = hold;
- break;
- } /* next piece is not a bitfield */
-
- /* In the general case, we can't allow
- full expressions with symbol
- differences and such. The relocation
- entries for symbols not defined in this
- assembly would require arbitrary field
- widths, positions, and masks which most
- of our current object formats don't
- support.
-
- In the specific case where a symbol
- *is* defined in this assembly, we
- *could* build fixups and track it, but
- this could lead to confusion for the
- backends. I'm lazy. I'll take any
- SEG_ABSOLUTE. I think that means that
- you can use a previous .set or
- .equ type symbol. xoxorich. */
-
- if (segment == SEG_ABSENT)
- {
- as_warn ("Using a bit field width of zero.");
- exp.X_add_number = 0;
- segment = SEG_ABSOLUTE;
- } /* implied zero width bitfield */
+ hold = ++input_line_pointer; /* skip ':' */
- if (segment != SEG_ABSOLUTE)
- {
- *input_line_pointer = '\0';
- as_bad ("Field width \"%s\" too complex for a bitfield.\n", hold);
- *input_line_pointer = ':';
- demand_empty_rest_of_line ();
- return;
- } /* too complex */
+ if ((segment = expression (exp)) != absolute_section)
+ {
+ char cache = *input_line_pointer;
- if ((width = exp.X_add_number) > (BITS_PER_CHAR * nbytes))
- {
- as_warn ("Field width %d too big to fit in %d bytes: truncated to %d bits.",
- width, nbytes, (BITS_PER_CHAR * nbytes));
- width = BITS_PER_CHAR * nbytes;
- } /* too big */
+ *input_line_pointer = '\0';
+ as_bad ("Field value \"%s\" too complex for a bitfield.\n", hold);
+ *input_line_pointer = cache;
+ demand_empty_rest_of_line ();
+ return;
+ } /* too complex */
- if (width > bits_available)
- {
- /* FIXME-SOMEDAY: backing up and
- reparsing is wasteful */
- input_line_pointer = hold;
- exp.X_add_number = value;
- break;
- } /* won't fit */
+ value |= (~(-1 << width) & exp->X_add_number)
+ << ((BITS_PER_CHAR * nbytes) - bits_available);
- hold = ++input_line_pointer; /* skip ':' */
+ if ((bits_available -= width) == 0
+ || is_it_end_of_statement ()
+ || *input_line_pointer != ',')
+ {
+ break;
+ } /* all the bitfields we're gonna get */
- if ((segment = expression (&exp)) != SEG_ABSOLUTE)
- {
- char cache = *input_line_pointer;
+ hold = ++input_line_pointer;
+ segment = expression (exp);
+ } /* forever loop */
- *input_line_pointer = '\0';
- as_bad ("Field value \"%s\" too complex for a bitfield.\n", hold);
- *input_line_pointer = cache;
- demand_empty_rest_of_line ();
- return;
- } /* too complex */
+ exp->X_add_number = value;
+ exp->X_seg = absolute_section;
+ } /* if looks like a bitfield */
+} /* parse_bitfield_cons() */
- value |= (~(-1 << width) & exp.X_add_number)
- << ((BITS_PER_CHAR * nbytes) - bits_available);
+#endif /* BITFIELD_CONS_EXPRESSIONS */
+\f
+#ifdef MRI
- if ((bits_available -= width) == 0
- || is_it_end_of_statement ()
- || *input_line_pointer != ',')
+static void
+parse_mri_cons (exp, nbytes)
+ expressionS *exp;
+ unsigned int nbytes;
+{
+ if (*input_line_pointer == '\'')
+ {
+ /* An MRI style string, cut into as many bytes as will fit into
+ a nbyte chunk, left justify if necessary, and separate with
+ commas so we can try again later */
+ int scan = 0;
+ unsigned int result = 0;
+ input_line_pointer++;
+ for (scan = 0; scan < nbytes; scan++)
+ {
+ if (*input_line_pointer == '\'')
+ {
+ if (input_line_pointer[1] == '\'')
{
- break;
- } /* all the bitfields we're gonna get */
+ input_line_pointer++;
+ }
+ else
+ break;
+ }
+ result = (result << 8) | (*input_line_pointer++);
+ }
+
+ /* Left justify */
+ while (scan < nbytes)
+ {
+ result <<= 8;
+ scan++;
+ }
+ /* Create correct expression */
+ exp->X_add_symbol = 0;
+ exp->X_add_number = result;
+ exp->X_seg = absolute_section;
+ /* Fake it so that we can read the next char too */
+ if (input_line_pointer[0] != '\'' ||
+ (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
+ {
+ input_line_pointer -= 2;
+ input_line_pointer[0] = ',';
+ input_line_pointer[1] = '\'';
+ }
+ else
+ input_line_pointer++;
+ }
+ else
+ expression (&exp);
+}
- hold = ++input_line_pointer;
- segment = expression (&exp);
- } /* forever loop */
+#endif /* MRI */
+\f
+#ifdef REPEAT_CONS_EXPRESSIONS
- exp.X_add_number = value;
- segment = SEG_ABSOLUTE;
- } /* if looks like a bitfield */
-#endif /* WANT_BITFIELDS */
+/* Parse a repeat expression for cons. This is used by the MIPS
+ assembler. The format is NUMBER:COUNT; NUMBER appears in the
+ object file COUNT times.
- if (!need_pass_2)
- { /* Still worthwhile making frags. */
+ To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
- /* Don't call this if we are going to junk this pass anyway! */
- know (segment != SEG_PASS1);
+static void
+parse_repeat_cons (exp, nbytes)
+ expressionS *exp;
+ unsigned int nbytes;
+{
+ expressionS count;
+ segT segment;
+ register int i;
- if (segment == SEG_DIFFERENCE && exp.X_add_symbol == NULL)
- {
- as_bad ("Subtracting symbol \"%s\"(segment\"%s\") is too hard. Absolute segment assumed.",
- S_GET_NAME (exp.X_subtract_symbol),
- segment_name (S_GET_SEGMENT (exp.X_subtract_symbol)));
- segment = SEG_ABSOLUTE;
- /* Leave exp . X_add_number alone. */
- }
- p = frag_more (nbytes);
- switch (segment)
- {
- case SEG_BIG:
- as_bad ("%s number invalid. Absolute 0 assumed.",
- exp.X_add_number > 0 ? "Bignum" : "Floating-Point");
- md_number_to_chars (p, (long) 0, nbytes);
- break;
+ expression (exp);
- case SEG_ABSENT:
- as_warn ("0 assumed for missing expression");
- exp.X_add_number = 0;
- know (exp.X_add_symbol == NULL);
- /* fall into SEG_ABSOLUTE */
- case SEG_ABSOLUTE:
- get = exp.X_add_number;
- use = get & unmask;
- if ((get & mask) && (get & mask) != mask)
- { /* Leading bits contain both 0s & 1s. */
- as_warn ("Value 0x%x truncated to 0x%x.", get, use);
- }
- md_number_to_chars (p, use, nbytes); /* put bytes in right order. */
- break;
+ if (*input_line_pointer != ':')
+ {
+ /* No repeat count. */
+ return;
+ }
- case SEG_DIFFERENCE:
-#ifndef WORKING_DOT_WORD
- if (nbytes == 2)
- {
- struct broken_word *x;
-
- x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
- x->next_broken_word = broken_words;
- broken_words = x;
- x->frag = frag_now;
- x->word_goes_here = p;
- x->dispfrag = 0;
- x->add = exp.X_add_symbol;
- x->sub = exp.X_subtract_symbol;
- x->addnum = exp.X_add_number;
- x->added = 0;
- new_broken_words++;
- break;
- }
- /* Else Fall through into. . . */
-#endif
- default:
- case SEG_UNKNOWN:
-#ifdef TC_NS32K
- fix_new_ns32k (frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, 0, 2, 0, 0);
-#else
-# if defined(TC_SPARC) || defined(TC_A29K)
- fix_new (frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, RELOC_32);
-# else
-# if defined(TC_H8300)
- fix_new (frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, R_RELWORD);
-
-# else
-#ifdef NO_RELOC
- fix_new (frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, NO_RELOC);
-#else
- fix_new (frag_now, p - frag_now->fr_literal, nbytes,
- exp.X_add_symbol, exp.X_subtract_symbol,
- exp.X_add_number, 0, 0);
-#endif /* NO_RELOC */
-# endif /* tc_h8300 */
-# endif /* tc_sparc|tc_a29k */
-#endif /* TC_NS32K */
- break;
- } /* switch(segment) */
- } /* if (!need_pass_2) */
- c = *input_line_pointer++;
- } /* while(c==',') */
- input_line_pointer--; /* Put terminator back into stream. */
- demand_empty_rest_of_line ();
-} /* cons() */
+ ++input_line_pointer;
+ segment = expression (&count);
+ if (segment != absolute_section
+ || count.X_add_number <= 0)
+ {
+ as_warn ("Unresolvable or nonpositive repeat count; using 1");
+ return;
+ }
+
+ /* The cons function is going to output this expression once. So we
+ output it count - 1 times. */
+ for (i = count.X_add_number - 1; i > 0; i--)
+ emit_expr (exp, nbytes);
+}
+
+#endif /* REPEAT_CONS_EXPRESSIONS */
\f
/*
* big_cons()
register int work; /* For multi-precision arithmetic. */
register char *p; /* For multi-precision arithmetic. */
- extern char hex_value[]; /* In hex_value.c. */
+ extern const char hex_value[]; /* In hex_value.c. */
/*
* The following awkward logic is to parse ZERO or more strings,
}
if (!need_pass_2)
{
+ char *src = bignum_low;
p = frag_more (nbytes);
- bcopy (bignum_low, p, (int) nbytes);
+ if (target_big_endian)
+ {
+ int i;
+ for (i = nbytes - 1; i >= 0; i--)
+ p[i] = *src++;
+ }
+ else
+ bcopy (bignum_low, p, (int) nbytes);
}
/* C contains character after number. */
SKIP_WHITESPACE ();
err = md_atof (float_type, temp, &length);
know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
know (length > 0);
- if (*err)
+ if (err && *err)
{
as_bad ("Bad floating literal: %s", err);
ignore_rest_of_line ();
/* Checks end-of-line. */
register int append_zero; /* 0: don't append '\0', else 1 */
{
- /* register char * p; JF unused */
- /* register int length; JF unused *//* Length of string we read, excluding */
- /* trailing '\0' implied by closing quote. */
- /* register char * where; JF unused */
- /* register fragS * fragP; JF unused */
register unsigned int c;
/*
{
register segT retval;
- if ((retval = expression (expP)) == SEG_PASS1 || retval == SEG_ABSENT || retval == SEG_BIG)
+ retval = expression (expP);
+ if (retval == pass1_section
+ || retval == absent_section
+ || retval == big_section)
{
as_bad ("Expected address expression: absolute 0 assumed");
- retval = expP->X_seg = SEG_ABSOLUTE;
+ retval = expP->X_seg = absolute_section;
expP->X_add_number = 0;
expP->X_add_symbol = expP->X_subtract_symbol = 0;
}
register expressionS *expP;
{
register segT retval;
- register char *name1;
- register char *name2;
+ register CONST char *name1;
+ register CONST char *name2;
- if ((retval = get_segmented_expression (expP)) == SEG_UNKNOWN)
+ if ((retval = get_segmented_expression (expP)) == undefined_section)
{
name1 = expP->X_add_symbol ? S_GET_NAME (expP->X_add_symbol) : "";
name2 = expP->X_subtract_symbol ?
as_warn ("Symbol \"%s\" undefined: absolute 0 assumed.",
name1 ? name1 : name2);
}
- retval = expP->X_seg = SEG_ABSOLUTE;
+ retval = expP->X_seg = absolute_section;
expP->X_add_number = 0;
expP->X_add_symbol = expP->X_subtract_symbol = NULL;
}
-#ifndef MANY_SEGMENTS
- know (retval == SEG_ABSOLUTE || retval == SEG_DATA || retval == SEG_TEXT || retval == SEG_BSS || retval == SEG_DIFFERENCE);
-#endif
+ know (retval == absolute_section
+ || retval == diff_section
+ || SEG_NORMAL (retval));
return (retval);
} /* get_known_segmented_expression() */
expressionS exp;
register segT s;
- if ((s = expression (&exp)) != SEG_ABSOLUTE)
+ if ((s = expression (&exp)) != absolute_section)
{
- if (s != SEG_ABSENT)
+ if (s != absent_section)
{
as_bad ("Bad Absolute Expression, absolute 0 assumed.");
}
segment = get_known_segmented_expression (&exp);
if (!need_pass_2)
{
- if (segment != now_seg && segment != SEG_ABSOLUTE)
+ if (segment != now_seg && segment != absolute_section)
as_warn ("Illegal segment \"%s\". Segment \"%s\" assumed.",
segment_name (segment),
segment_name (now_seg));
s_ignore (arg)
int arg;
{
- extern char is_end_of_line[];
-
while (!is_end_of_line[*input_line_pointer])
{
++input_line_pointer;