From b3b91714e232061888a000aa811cebbcf1cb61b7 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 7 Nov 2005 06:01:18 +0000 Subject: [PATCH] * config/tc-i386.h (tc_comment_chars): Define. * config/tc-i386.c (line_comment_chars): Use '/' unconditionally. (i386_comment_chars): Add. (md_parse_options): Process OPTION_DIVIDE. (md_show_usage): Describe --divide option. * doc/c-i386.texi: Document --divide option. --- gas/ChangeLog | 9 +++++++ gas/config/tc-i386.c | 61 +++++++++++++++++++++++++++++++------------- gas/config/tc-i386.h | 3 +++ gas/doc/c-i386.texi | 9 +++++++ 4 files changed, 64 insertions(+), 18 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 7de85364e6..b7ec09a04f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2005-11-07 John Levon + + * config/tc-i386.h (tc_comment_chars): Define. + * config/tc-i386.c (line_comment_chars): Use '/' unconditionally. + (i386_comment_chars): Add. + (md_parse_options): Process OPTION_DIVIDE. + (md_show_usage): Describe --divide option. + * doc/c-i386.texi: Document --divide option. + 2005-11-07 Arnold Metselaar * expr.c (op_encoding): Map '=' to O_SINGLE_EQ, if defined. diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index a3cd6c8ca7..26121907fb 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -203,10 +203,17 @@ const char extra_symbol_chars[] = "*%-([" && !defined (TE_FreeBSD) \ && !defined (TE_NetBSD))) /* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful. */ -const char comment_chars[] = "#/"; + pre-processor is disabled, these aren't very useful. The option + --divide will remove '/' from this list. */ +const char *i386_comment_chars = "#/"; +#define SVR4_COMMENT_CHARS 1 #define PREFIX_SEPARATOR '\\' +#else +const char *i386_comment_chars = "#"; +#define PREFIX_SEPARATOR '/' +#endif + /* This array holds the chars that only start a comment at the beginning of a line. If the line seems to have the form '# 123 filename' .line and .file directives will appear in the pre-processed output. @@ -215,16 +222,7 @@ const char comment_chars[] = "#/"; #NO_APP at the beginning of its output. Also note that comments started like this one will always work if '/' isn't otherwise defined. */ -const char line_comment_chars[] = "#"; - -#else -/* Putting '/' here makes it impossible to use the divide operator. - However, we need it for compatibility with SVR4 systems. */ -const char comment_chars[] = "#"; -#define PREFIX_SEPARATOR '/' - -const char line_comment_chars[] = "/#"; -#endif +const char line_comment_chars[] = "#/"; const char line_separator_chars[] = ";"; @@ -5302,13 +5300,16 @@ const char *md_shortopts = "kVQ:sqn"; const char *md_shortopts = "qn"; #endif -struct option md_longopts[] = { #define OPTION_32 (OPTION_MD_BASE + 0) +#define OPTION_64 (OPTION_MD_BASE + 1) +#define OPTION_DIVIDE (OPTION_MD_BASE + 2) + +struct option md_longopts[] = { {"32", no_argument, NULL, OPTION_32}, #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) -#define OPTION_64 (OPTION_MD_BASE + 1) {"64", no_argument, NULL, OPTION_64}, #endif + {"divide", no_argument, NULL, OPTION_DIVIDE}, {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof (md_longopts); @@ -5370,6 +5371,23 @@ md_parse_option (c, arg) default_arch = "i386"; break; + case OPTION_DIVIDE: +#ifdef SVR4_COMMENT_CHARS + { + char *n, *t; + const char *s; + + n = (char *) xmalloc (strlen (i386_comment_chars) + 1); + t = n; + for (s = i386_comment_chars; *s != '\0'; s++) + if (*s != '/') + *t++ = *s; + *t = '\0'; + i386_comment_chars = n; + } +#endif + break; + default: return 0; } @@ -5384,14 +5402,21 @@ md_show_usage (stream) fprintf (stream, _("\ -Q ignored\n\ -V print assembler version number\n\ - -k ignored\n\ + -k ignored\n")); +#endif + fprintf (stream, _("\ -n Do not optimize code alignment\n\ - -q quieten some warnings\n\ + -q quieten some warnings\n")); +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) + fprintf (stream, _("\ -s ignored\n")); +#endif +#ifdef SVR4_COMMENT_CHARS + fprintf (stream, _("\ + --divide do not treat `/' as a comment character\n")); #else fprintf (stream, _("\ - -n Do not optimize code alignment\n\ - -q quieten some warnings\n")); + --divide ignored\n")); #endif } diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 40b92b0feb..0a9cd1c082 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -88,6 +88,9 @@ extern void i386_elf_emit_arch_note PARAMS ((void)); extern const char extra_symbol_chars[]; #define tc_symbol_chars extra_symbol_chars +extern const char *i386_comment_chars; +#define tc_comment_chars i386_comment_chars + #define MAX_OPERANDS 3 /* max operands per insn */ #define MAX_IMMEDIATE_OPERANDS 2/* max immediates per insn (lcall, ljmp) */ #define MAX_MEMORY_OPERANDS 2 /* max memory refs per insn (string ops) */ diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi index 678dfe34de..81039c4dbe 100644 --- a/gas/doc/c-i386.texi +++ b/gas/doc/c-i386.texi @@ -67,6 +67,15 @@ usage and use x86-64 as target platform). By default, x86 GAS replaces multiple nop instructions used for alignment within code sections with multi-byte nop instructions such as leal 0(%esi,1),%esi. This switch disables the optimization. + +@cindex @samp{--divide} option, i386 +@item --divide +On SVR4-derived platforms, the character @samp{/} is treated as a comment +character, which means that it cannot be used in expressions. The +@samp{--divide} option turns @samp{/} into a normal character. This does +not disable @samp{/} at the beginning of a line starting a comment, or +affect using @samp{#} for starting a comment. + @end table @node i386-Syntax -- 2.34.1