This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
PATCH GAS numbers with radix in suffix
- To: binutils at sourceware dot cygnus dot com, nickc at cygnus dot com
- Subject: PATCH GAS numbers with radix in suffix
- From: Timothy Wall <twall at domesolutions dot com>
- Date: Mon, 07 Feb 2000 13:03:46 -0500
- Organization: Dome Solutions
This patch allows GAS to properly parse constants with the suffix in the
radix, e.g.
0101001b (binary)
0FFFEh (hex)
0774Q (octal)
* gas/doc/internals.texi: Document NUMBERS_WITH_SUFFIX option.
* gas/as.h: Provide a default NUMBERS_WITH_SUFFIX definition (zero).
* gas/expr.c: Handle numbers with suffixes if NUMBERS_WITH_SUFFIX is
non-zero.
Index: gas/doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.4
diff -d -c -p -r1.4 internals.texi
*** internals.texi 1999/09/12 03:44:42 1.4
--- internals.texi 2000/02/07 17:52:54
*************** default value it zero.
*** 960,965 ****
--- 960,971 ----
You may define this macro to the lexical type of the @kbd{$} character. The
default value is @code{LEX_NAME | LEX_BEGIN_NAME}.
+ @item NUMBERS_WITH_SUFFIX
+ @cindex NUMBERS_WITH_SUFFIX
+ When this macro is defined to be non-zero, the parser allows the radix of a
+ constant to be indicated with a suffix. Valid suffixes are binary (B),
+ octal (Q), and hexadecimal (H).
+
@item SINGLE_QUOTE_STRINGS
@cindex SINGLE_QUOTE_STRINGS
If you define this macro, GAS will treat single quotes as string delimiters.
Index: gas/as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.6
diff -d -c -p -r1.6 as.h
*** as.h 2000/02/03 18:20:23 1.6
--- as.h 2000/02/07 17:52:54
*************** void eh_frame_convert_frag PARAMS ((frag
*** 629,634 ****
--- 629,638 ----
#endif
#include "listing.h"
+ #ifndef NUMBERS_WITH_SUFFIX
+ #define NUMBERS_WITH_SUFFIX 0
+ #endif
+
#ifndef LOCAL_LABELS_DOLLAR
#define LOCAL_LABELS_DOLLAR 0
#endif
Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.9
diff -d -c -p -r1.9 expr.c
*** expr.c 1999/11/05 21:50:54 1.9
--- expr.c 2000/02/07 17:52:55
*************** integer_constant (radix, expressionP)
*** 327,333 ****
#define valuesize 32
#endif
! if (flag_m68k_mri && radix == 0)
{
int flt = 0;
--- 327,333 ----
#define valuesize 32
#endif
! if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) && radix == 0)
{
int flt = 0;
*************** integer_constant (radix, expressionP)
*** 541,547 ****
}
}
! if (flag_m68k_mri && suffix != NULL && input_line_pointer - 1 == suffix)
c = *input_line_pointer++;
if (small)
--- 541,549 ----
}
}
! if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
! && suffix != NULL
! && input_line_pointer - 1 == suffix)
c = *input_line_pointer++;
if (small)
*************** operand (expressionP)
*** 810,822 ****
case '9':
input_line_pointer--;
! integer_constant (flag_m68k_mri ? 0 : 10, expressionP);
break;
case '0':
/* non-decimal radix */
! if (flag_m68k_mri)
{
char *s;
--- 812,825 ----
case '9':
input_line_pointer--;
! integer_constant ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) ?
! 0 : 10, expressionP);
break;
case '0':
/* non-decimal radix */
! if (NUMBERS_WITH_SUFFIX || flag_m68k_mri)
{
char *s;
*************** operand (expressionP)
*** 829,836 ****
integer_constant (0, expressionP);
break;
}
! }
!
c = *input_line_pointer;
switch (c)
{
--- 832,857 ----
integer_constant (0, expressionP);
break;
}
! if (NUMBERS_WITH_SUFFIX)
! {
! /* Check for a binary constant. */
! for (s = input_line_pointer; *s == '0' || *s == '1'; s++)
! ;
! if (toupper (*s) == 'B')
! {
! integer_constant (0, expressionP);
! break;
! }
! /* Check for an octal constant. */
! for (s = input_line_pointer; *s >= '0' && *s <= '7'; s++)
! ;
! if (toupper (*s) == 'Q')
! {
! integer_constant (0, expressionP);
! break;
! }
! }
! }
c = *input_line_pointer;
switch (c)
{
*************** operand (expressionP)
*** 840,846 ****
case 'Q':
case '8':
case '9':
! if (flag_m68k_mri)
{
integer_constant (0, expressionP);
break;
--- 861,867 ----
case 'Q':
case '8':
case '9':
! if (NUMBERS_WITH_SUFFIX || flag_m68k_mri)
{
integer_constant (0, expressionP);
break;
*************** operand (expressionP)
*** 873,879 ****
break;
case 'b':
! if (LOCAL_LABELS_FB && ! flag_m68k_mri)
{
/* This code used to check for '+' and '-' here, and, in
some conditions, fall through to call
--- 894,900 ----
break;
case 'b':
! if (LOCAL_LABELS_FB && ! flag_m68k_mri && ! NUMBERS_WITH_SUFFIX)
{
/* This code used to check for '+' and '-' here, and, in
some conditions, fall through to call