aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorJohn Darrington <john@darrington.wattle.id.au>2019-05-22 07:16:14 +0200
committerJohn Darrington <john@darrington.wattle.id.au>2019-05-22 08:13:36 +0200
commit22c6ccb89e0f38a70a42fb49eb167e7857d51f5c (patch)
tree53939413dadacc46e7b3c2975212e52e9cf5ad6d /gas/config
parenta7df56e5f840e2ce8bb09487ee0b6570cddb1550 (diff)
downloadgdb-22c6ccb89e0f38a70a42fb49eb167e7857d51f5c.zip
gdb-22c6ccb89e0f38a70a42fb49eb167e7857d51f5c.tar.gz
gdb-22c6ccb89e0f38a70a42fb49eb167e7857d51f5c.tar.bz2
S12Z: GAS: New option --mdollar-hex.
This option (also implied by --traditional) causes '$' to introduce literal hexadecimal constants, rather than the modern convention '0x'. gas/ * config/tc-s12z.c (s12z_strtol): New function. (md_show_usage): Update. (md_parse_option): new case OPTION_DOLLAR_HEX. (s12z_init_after_args): (<global>): Use s12z_strtol instead of strtol. * doc/c-s12z.texi (S12Z Options): Document new option -mdollar-hex. * testsuite/gas/s12z/dollar-hex.d: New file. * testsuite/gas/s12z/dollar-hex.s: New file. * testsuite/gas/s12z/s12z.exp: Add them.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-s12z.c67
1 files changed, 59 insertions, 8 deletions
diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c
index 568f7b5..67e88d2 100644
--- a/gas/config/tc-s12z.c
+++ b/gas/config/tc-s12z.c
@@ -39,6 +39,50 @@ const char FLT_CHARS[] = "dD";
static char *fail_line_pointer;
+/* A wrapper around the standard library's strtol.
+ It converts STR into an integral value.
+ This wrapper deals with literal_prefix_dollar_hex. */
+static long
+s12z_strtol (const char *str, char ** endptr)
+{
+ int base = 0;
+ bool negative = false;
+
+ long result = 0;
+
+ char *start = (char *) str;
+
+ /* In the case where literal_prefix_dollar_hex is TRUE the sign has
+ to be handled explicitly. Otherwise the string will not be
+ recognised as an integer. */
+ if (str[0] == '-')
+ {
+ negative = true;
+ ++str;
+ }
+ else if (str[0] == '+')
+ {
+ ++str;
+ }
+
+ if (literal_prefix_dollar_hex && (str[0] == '$'))
+ {
+ base = 16;
+ str++;
+ }
+
+ result = strtol (str, endptr, base);
+ if (*endptr == str)
+ {
+ *endptr = start;
+ }
+ if (negative)
+ result = -result;
+
+ return result;
+}
+
+
/* Options and initialization. */
@@ -46,7 +90,10 @@ const char *md_shortopts = "";
struct option md_longopts[] =
{
- {"mreg-prefix", required_argument, NULL, OPTION_MD_BASE},
+#define OPTION_REG_PREFIX (OPTION_MD_BASE)
+ {"mreg-prefix", required_argument, NULL, OPTION_REG_PREFIX},
+#define OPTION_DOLLAR_HEX (OPTION_MD_BASE + 1)
+ {"mdollar-hex", no_argument, NULL, OPTION_DOLLAR_HEX},
{NULL, no_argument, NULL, 0}
};
@@ -98,10 +145,9 @@ s12z_listing_header (void)
void
md_show_usage (FILE *stream)
{
- fprintf (stream,
- _("\ns12z options:\n"
- " -mreg-prefix=PREFIX set a prefix used to indicate register names (default none)"
- "\n"));
+ fputs (_("\ns12z options:\n"), stream);
+ fputs (_(" -mreg-prefix=PREFIX set a prefix used to indicate register names (default none)\n"), stream);
+ fputs (_(" -mdollar-hex the prefix '$' instead of '0x' is used to indicate literal hexadecimal constants\n"), stream);
}
void
@@ -114,9 +160,12 @@ md_parse_option (int c, const char *arg)
{
switch (c)
{
- case OPTION_MD_BASE:
+ case OPTION_REG_PREFIX:
register_prefix = xstrdup (arg);
break;
+ case OPTION_DOLLAR_HEX:
+ literal_prefix_dollar_hex = TRUE;
+ break;
default:
return 0;
}
@@ -150,6 +199,8 @@ md_begin (void)
void
s12z_init_after_args (void)
{
+ if (flag_traditional_format)
+ literal_prefix_dollar_hex = TRUE;
}
/* Builtin help. */
@@ -198,7 +249,7 @@ lex_constant (long *v)
}
errno = 0;
- *v = strtol (p, &end, 0);
+ *v = s12z_strtol (p, &end);
if (errno == 0 && end != p)
{
input_line_pointer = end;
@@ -716,7 +767,7 @@ lex_offset (long *val)
p++;
errno = 0;
- *val = strtol (p, &end, 0);
+ *val = s12z_strtol (p, &end);
if (errno == 0)
{
if (negative)