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.
This commit is contained in:
parent
a7df56e5f8
commit
22c6ccb89e
|
@ -1,3 +1,13 @@
|
|||
2019-05-22 John Darrington <john@darrington.wattle.id.au>
|
||||
|
||||
* 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.
|
||||
|
||||
2019-05-21 Sudakshina Das <sudi.das@arm.com>
|
||||
|
||||
* config/tc-arm.c (parse_operands): Update case OP_RVC to
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -38,6 +38,19 @@ string @var{pfx}.
|
|||
|
||||
For an explanation of what this means and why it might be needed,
|
||||
see @ref{S12Z Register Notation}.
|
||||
|
||||
|
||||
@item -mdollar-hex
|
||||
@cindex @samp{-mdollar-hex} option, dollar-hex
|
||||
@cindex hexadecimal prefix, S12Z
|
||||
The @samp{-mdollar-hex} option affects the way that literal hexadecimal constants
|
||||
are represented. When this option is specified, the assembler will consider
|
||||
the @samp{$} character as the start of a hexadecimal integer constant. Without
|
||||
this option, the standard value of @samp{0x} is expected.
|
||||
|
||||
If you use this option, then you cannot have symbol names starting with @samp{$}.
|
||||
@samp{-mdollar-hex} is implied if the @samp{--traditional-format}
|
||||
(@pxref{traditional-format}) is used.
|
||||
@end table
|
||||
|
||||
@node S12Z Syntax
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#objdump: -d
|
||||
#name: Dollar sign as literal hex prefix
|
||||
#source: dollar-hex.s --mdollar-hex
|
||||
|
||||
tmpdir/dollar-hex.o: file format elf32-s12z
|
||||
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
00000000 <.text>:
|
||||
0: 1c bc e0 18 mov.b d0, \(24,s\)
|
||||
4: dc fa 12 34 neg.b 1193046
|
||||
8: 56
|
||||
9: 98 12 34 56 ld x, #1193046
|
||||
d: aa e1 dd jmp \(-35,s\)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
mov.b d0, ($18,s)
|
||||
neg.b $123456
|
||||
ld x, #$123456
|
||||
jmp (-$23, s) ; Make sure this isn't misinterpreted as the start of a predecrement operand
|
|
@ -142,3 +142,4 @@ run_dump_test imm-dest
|
|||
# Miscellaneous
|
||||
|
||||
run_dump_test reg-prefix
|
||||
run_dump_test dollar-hex
|
||||
|
|
Loading…
Reference in New Issue