extern fragS bss_address_frag;
\f
/* Initialization for frag routines. */
+
void
frag_init ()
{
/* Allocate a frag on the specified obstack.
Call this routine from everywhere else, so that all the weird alignment
hackery can be done in just one place. */
+
fragS *
frag_alloc (ob)
struct obstack *ob;
return ptr;
}
\f
-/*
- * frag_grow()
- *
- * Try to augment current frag by nchars chars.
- * If there is no room, close of the current frag with a ".fill 0"
- * and begin a new frag. Unless the new frag has nchars chars available
- * do not return. Do not set up any fields of *now_frag.
- */
-void
+/* Try to augment current frag by nchars chars.
+ If there is no room, close of the current frag with a ".fill 0"
+ and begin a new frag. Unless the new frag has nchars chars available
+ do not return. Do not set up any fields of *now_frag. */
+
+void
frag_grow (nchars)
unsigned int nchars;
{
as_fatal (_("Can't extend frag %d. chars"), nchars);
}
\f
-/*
- * frag_new()
- *
- * Call this to close off a completed frag, and start up a new (empty)
- * frag, in the same subsegment as the old frag.
- * [frchain_now remains the same but frag_now is updated.]
- * Because this calculates the correct value of fr_fix by
- * looking at the obstack 'frags', it needs to know how many
- * characters at the end of the old frag belong to the maximal
- * variable part; The rest must belong to fr_fix.
- * It doesn't actually set up the old frag's fr_var. You may have
- * set fr_var == 1, but allocated 10 chars to the end of the frag;
- * In this case you pass old_frags_var_max_size == 10.
- * In fact, you may use fr_var for something totally unrelated to the
- * size of the variable part of the frag; None of the generic frag
- * handling code makes use of fr_var.
- *
- * Make a new frag, initialising some components. Link new frag at end
- * of frchain_now.
- */
-void
+/* Call this to close off a completed frag, and start up a new (empty)
+ frag, in the same subsegment as the old frag.
+ [frchain_now remains the same but frag_now is updated.]
+ Because this calculates the correct value of fr_fix by
+ looking at the obstack 'frags', it needs to know how many
+ characters at the end of the old frag belong to the maximal
+ variable part; The rest must belong to fr_fix.
+ It doesn't actually set up the old frag's fr_var. You may have
+ set fr_var == 1, but allocated 10 chars to the end of the frag;
+ In this case you pass old_frags_var_max_size == 10.
+ In fact, you may use fr_var for something totally unrelated to the
+ size of the variable part of the frag; None of the generic frag
+ handling code makes use of fr_var.
+
+ Make a new frag, initialising some components. Link new frag at end
+ of frchain_now. */
+
+void
frag_new (old_frags_var_max_size)
/* Number of chars (already allocated on obstack frags) in
- variable_length part of frag. */
+ variable_length part of frag. */
int old_frags_var_max_size;
{
fragS *former_last_fragP;
assert (frag_now->fr_type != 0);
/* This will align the obstack so the next struct we allocate on it
- will begin at a correct boundary. */
+ will begin at a correct boundary. */
obstack_finish (&frchain_now->frch_obstack);
frchP = frchain_now;
know (frchP);
/* Generally, frag_now->points to an address rounded up to next
alignment. However, characters will add to obstack frags
IMMEDIATELY after the struct frag, even if they are not starting
- at an alignment address. */
+ at an alignment address. */
former_last_fragP->fr_next = frag_now;
frchP->frch_last = frag_now;
assert (frchain_now->frch_last == frag_now);
frag_now->fr_next = NULL;
-} /* frag_new() */
+}
\f
-/*
- * frag_more()
- *
- * Start a new frag unless we have n more chars of room in the current frag.
- * Close off the old frag with a .fill 0.
- *
- * Return the address of the 1st char to write into. Advance
- * frag_now_growth past the new chars.
- */
+/* Start a new frag unless we have n more chars of room in the current frag.
+ Close off the old frag with a .fill 0.
+
+ Return the address of the 1st char to write into. Advance
+ frag_now_growth past the new chars. */
char *
frag_more (nchars)
retval = obstack_next_free (&frchain_now->frch_obstack);
obstack_blank_fast (&frchain_now->frch_obstack, nchars);
return (retval);
-} /* frag_more() */
+}
\f
-/*
- * frag_var()
- *
- * Start a new frag unless we have max_chars more chars of room in the current frag.
- * Close off the old frag with a .fill 0.
- *
- * Set up a machine_dependent relaxable frag, then start a new frag.
- * Return the address of the 1st char of the var part of the old frag
- * to write into.
- */
+/* Start a new frag unless we have max_chars more chars of room in the
+ current frag. Close off the old frag with a .fill 0.
+
+ Set up a machine_dependent relaxable frag, then start a new frag.
+ Return the address of the 1st char of the var part of the old frag
+ to write into. */
char *
frag_var (type, max_chars, var, subtype, symbol, offset, opcode)
return (retval);
}
\f
-/*
- * frag_variant()
- *
- * OVE: This variant of frag_var assumes that space for the tail has been
- * allocated by caller.
- * No call to frag_grow is done.
- */
+/* OVE: This variant of frag_var assumes that space for the tail has been
+ allocated by caller.
+ No call to frag_grow is done. */
char *
frag_variant (type, max_chars, var, subtype, symbol, offset, opcode)
as_where (&frag_now->fr_file, &frag_now->fr_line);
frag_new (max_chars);
return (retval);
-} /* frag_variant() */
+}
\f
-/*
- * frag_wane()
- *
- * Reduce the variable end of a frag to a harmless state.
- */
-void
+/* Reduce the variable end of a frag to a harmless state. */
+
+void
frag_wane (fragP)
register fragS *fragP;
{
the maximum number of characters to skip when doing the alignment,
or 0 if there is no maximum. */
-void
+void
frag_align (alignment, fill_character, max)
int alignment;
int fill_character;
addressT new_off;
addressT mask;
- mask = (~ (addressT) 0) << alignment;
- new_off = (abs_section_offset + ~ mask) & mask;
+ mask = (~(addressT) 0) << alignment;
+ new_off = (abs_section_offset + ~mask) & mask;
if (max == 0 || new_off - abs_section_offset <= (addressT) max)
abs_section_offset = new_off;
}
FILL_PATTERN. MAX is the maximum number of characters to skip when
doing the alignment, or 0 if there is no maximum. */
-void
+void
frag_align_pattern (alignment, fill_pattern, n_fill, max)
int alignment;
const char *fill_pattern;
if (now_seg == absolute_section)
return abs_section_offset;
- return ((char*) obstack_next_free (&frchain_now->frch_obstack)
- - frag_now->fr_literal);
+ return ((char *) obstack_next_free (&frchain_now->frch_obstack)
+ - frag_now->fr_literal);
}
addressT
frag_now_fix ()
{
- return frag_now_fix_octets() / OCTETS_PER_BYTE;
+ return frag_now_fix_octets () / OCTETS_PER_BYTE;
}
void
}
obstack_1grow (&frchain_now->frch_obstack, datum);
}
-
-/* end of frags.c */
/* macro.c - macro support for gas and gasp
- Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1994, 95, 96, 97, 98, 99, 2000
+ Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
sac@cygnus.com
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ 02111-1307, USA. */
#include "config.h"
while (more)
{
- /* Try and find the first pseudo op on the line */
+ /* Try and find the first pseudo op on the line. */
int i = line_start;
if (! macro_alternate && ! macro_mri)
/* With normal syntax we can suck what we want till we get
to the dot. With the alternate, labels have to start in
the first column, since we cant tell what's a label and
- whats a pseudoop */
+ whats a pseudoop. */
- /* Skip leading whitespace */
+ /* Skip leading whitespace. */
while (i < ptr->len && ISWHITE (ptr->ptr[i]))
i++;
- /* Skip over a label */
+ /* Skip over a label. */
while (i < ptr->len
&& (isalnum ((unsigned char) ptr->ptr[i])
|| ptr->ptr[i] == '_'
|| ptr->ptr[i] == '$'))
i++;
- /* And a colon */
+ /* And a colon. */
if (i < ptr->len
&& ptr->ptr[i] == ':')
i++;
}
- /* Skip trailing whitespace */
+ /* Skip trailing whitespace. */
while (i < ptr->len && ISWHITE (ptr->ptr[i]))
i++;
|| macro_mri))
{
if (ptr->ptr[i] == '.')
- i++;
+ i++;
if (strncasecmp (ptr->ptr + i, from, from_len) == 0
- && (ptr->len == (i + from_len) || ! isalnum (ptr->ptr[i + from_len])))
+ && (ptr->len == (i + from_len)
+ || ! isalnum (ptr->ptr[i + from_len])))
depth++;
if (strncasecmp (ptr->ptr + i, to, to_len) == 0
- && (ptr->len == (i + to_len) || ! isalnum (ptr->ptr[i + to_len])))
+ && (ptr->len == (i + to_len)
+ || ! isalnum (ptr->ptr[i + to_len])))
{
depth--;
if (depth == 0)
{
- /* Reset the string to not include the ending rune */
+ /* Reset the string to not include the ending rune. */
ptr->len = line_start;
break;
}
}
}
- /* Add a CR to the end and keep running */
+ /* Add a CR to the end and keep running. */
sb_add_char (ptr, '\n');
line_start = ptr->len;
more = get_line (ptr);
sb_add_char (name, in->ptr[idx++]);
}
}
- /* Ignore trailing & */
+ /* Ignore trailing &. */
if (macro_alternate && idx < in->len && in->ptr[idx] == '&')
idx++;
return idx;
idx = sb_skip_white (idx, in);
while (idx < in->len
- && (in->ptr[idx] == '"'
+ && (in->ptr[idx] == '"'
|| (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
|| (in->ptr[idx] == '\'' && macro_alternate)))
{
{
if (in->ptr[idx] == '!')
{
- idx++ ;
+ idx++;
sb_add_char (acc, in->ptr[idx++]);
}
else
{
char tchar = in->ptr[idx];
int escaped = 0;
-
+
idx++;
-
+
while (idx < in->len)
{
- if (in->ptr[idx-1] == '\\')
+ if (in->ptr[idx - 1] == '\\')
escaped ^= 1;
else
escaped = 0;
if (macro_alternate && in->ptr[idx] == '!')
{
- idx ++;
-
+ idx++;
+
sb_add_char (acc, in->ptr[idx]);
- idx ++;
+ idx++;
}
else if (escaped && in->ptr[idx] == tchar)
{
sb_add_char (acc, tchar);
- idx ++;
+ idx++;
}
else
{
if (in->ptr[idx] == tchar)
{
- idx ++;
-
+ idx++;
+
if (idx >= in->len || in->ptr[idx] != tchar)
break;
}
-
+
sb_add_char (acc, in->ptr[idx]);
- idx ++;
+ idx++;
}
}
}
}
-
+
return idx;
}
if (idx < in->len)
{
- if (in->len > 2 && in->ptr[idx+1] == '\'' && ISBASE (in->ptr[idx]))
+ if (in->len > 2 && in->ptr[idx + 1] == '\'' && ISBASE (in->ptr[idx]))
{
while (!ISSEP (in->ptr[idx]))
sb_add_char (out, in->ptr[idx++]);
{
int val;
char buf[20];
- /* Turns the next expression into a string */
+ /* Turns the next expression into a string. */
idx = (*macro_expr) (_("% operator needs absolute expression"),
idx + 1,
in,
&& ! macro_strip_at
&& expand)
{
- /* Keep the quotes */
- sb_add_char (out, '\"');
+ /* Keep the quotes. */
+ sb_add_char (out, '\"');
idx = getstring (idx, in, out);
- sb_add_char (out, '\"');
+ sb_add_char (out, '\"');
}
else
{
idx = getstring (idx, in, out);
}
}
- else
+ else
{
- while (idx < in->len
+ while (idx < in->len
&& (in->ptr[idx] == '"'
|| in->ptr[idx] == '\''
- || pretend_quoted
+ || pretend_quoted
|| (in->ptr[idx] != ' '
&& in->ptr[idx] != '\t'
&& in->ptr[idx] != ','
&& (in->ptr[idx] != '<'
|| (! macro_alternate && ! macro_mri)))))
{
- if (in->ptr[idx] == '"'
+ if (in->ptr[idx] == '"'
|| in->ptr[idx] == '\'')
{
char tchar = in->ptr[idx];
sb_add_char (out, in->ptr[idx++]);
while (idx < in->len
&& in->ptr[idx] != tchar)
- sb_add_char (out, in->ptr[idx++]);
+ sb_add_char (out, in->ptr[idx++]);
if (idx == in->len)
- return idx;
+ return idx;
}
sb_add_char (out, in->ptr[idx++]);
}
idx = sb_skip_white (idx, in);
if (formal->name.len)
{
- /* This is a formal */
+ /* This is a formal. */
if (idx < in->len && in->ptr[idx] == '=')
{
- /* Got a default */
+ /* Got a default. */
idx = get_any_string (idx + 1, in, &formal->def, 1, 0);
}
}
- /* Add to macro's hash table */
+ /* Add to macro's hash table. */
hash_jam (macro->formal_hash, sb_terminate (&formal->name), formal);
formal->index = macro->formal_count;
sb_add_string (&formal->name, name);
- /* Add to macro's hash table */
+ /* Add to macro's hash table. */
hash_jam (macro->formal_hash, name, formal);
formal->index = NARG_INDEX;
sb_add_sb (&name, label);
if (idx < in->len && in->ptr[idx] == '(')
{
- /* It's the label: MACRO (formals,...) sort */
+ /* It's the label: MACRO (formals,...) sort */
idx = do_formals (macro, idx + 1, in);
if (in->ptr[idx] != ')')
return _("missing ) after formals");
}
else
{
- /* It's the label: MACRO formals,... sort */
+ /* It's the label: MACRO formals,... sort */
idx = do_formals (macro, idx, in);
}
}
idx = do_formals (macro, idx, in);
}
- /* and stick it in the macro hash table */
+ /* And stick it in the macro hash table. */
for (idx = 0; idx < name.len; idx++)
if (isupper ((unsigned char) name.ptr[idx]))
name.ptr[idx] = tolower (name.ptr[idx]);
{
sb_add_sb (out, t);
}
- else
+ else
{
sb_add_char (out, '\\');
sb_add_sb (out, t);
src++;
if (in->ptr[src] == comment_char && comment_char != '\0')
{
- /* This is a comment, just drop the rest of the line */
+ /* This is a comment, just drop the rest of the line. */
while (src < in->len
&& in->ptr[src] != '\n')
src++;
}
else if (in->ptr[src] == '(')
{
- /* Sub in till the next ')' literally */
+ /* Sub in till the next ')' literally. */
src++;
while (src < in->len && in->ptr[src] != ')')
{
}
else if (in->ptr[src] == '@')
{
- /* Sub in the macro invocation number */
+ /* Sub in the macro invocation number. */
char buffer[10];
src++;
else if (in->ptr[src] == '&')
{
/* This is a preprocessor variable name, we don't do them
- here */
+ here. */
sb_add_char (out, '\\');
sb_add_char (out, '&');
src++;
const char *err;
sb_new (&t);
-
- /* Reset any old value the actuals may have */
+
+ /* Reset any old value the actuals may have. */
for (f = m->formals; f; f = f->next)
- sb_reset (&f->actual);
+ sb_reset (&f->actual);
f = m->formals;
while (f != NULL && f->index < 0)
f = f->next;
}
}
- /* Peel off the actuals and store them away in the hash tables' actuals */
+ /* Peel off the actuals and store them away in the hash tables' actuals. */
idx = sb_skip_white (idx, in);
while (idx < in->len && in->ptr[idx] != comment_char)
{
int scan;
- /* Look and see if it's a positional or keyword arg */
+ /* Look and see if it's a positional or keyword arg. */
scan = idx;
while (scan < in->len
&& !ISSEP (in->ptr[scan])
/* It's OK to go from positional to keyword. */
/* This is a keyword arg, fetch the formal name and
- then the actual stuff */
+ then the actual stuff. */
sb_reset (&t);
idx = get_token (idx, in, &t);
if (in->ptr[idx] != '=')
return _("confusion in formal parameters");
- /* Lookup the formal in the macro's list */
+ /* Lookup the formal in the macro's list. */
ptr = (formal_entry *) hash_find (m->formal_hash, sb_terminate (&t));
if (!ptr)
return _("macro formal argument does not exist");
else
{
- /* Insert this value into the right place */
+ /* Insert this value into the right place. */
sb_reset (&ptr->actual);
idx = get_any_string (idx + 1, in, &ptr->actual, 0, 0);
if (ptr->actual.len > 0)
}
else
{
- /* This is a positional arg */
+ /* This is a positional arg. */
is_positional = 1;
if (is_keyword)
return _("can't mix positional and keyword arguments");
sb_kill (&line_sb);
- /* export the macro information if requested */
+ /* Export the macro information if requested. */
if (info)
*info = macro;
sb_new (&sub);
if (! buffer_and_nest (mn, "ENDR", &sub, get_line))
return _("unexpected end of file in irp or irpc");
-
+
sb_new (&f.name);
sb_new (&f.def);
sb_new (&f.actual);