From 6dc19fc4d614ca0d241cace28ea999dcf9f2888f Mon Sep 17 00:00:00 2001 From: Timothy Wall Date: Tue, 8 Feb 2000 19:06:00 +0000 Subject: [PATCH] Remove redundant code for checking numbers with suffixes. Add functionality to break out of assembler loops. --- gas/ChangeLog | 10 ++++++++++ gas/expr.c | 31 +++++++------------------------ gas/read.c | 38 ++++++++++++++++++++++++++++++++++---- gas/read.h | 2 ++ 4 files changed, 53 insertions(+), 28 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 807ea282d18..171a2779648 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2000-02-08 Timothy Wall + + * read.c (s_rept): Call do_repeat, which abstracts the repeat + logic. + (do_repeat): New. Abstract repeat logic so that a "break" can be + implemented. + (end_repeat): New. Provide support for a "break" out of the + repeat loop. + * read.h: Add prototypes for new functions. + 2000-02-08 Timothy Wall * doc/internals.texi: Document NUMBERS_WITH_SUFFIX macro. diff --git a/gas/expr.c b/gas/expr.c index e2e64991e46..cf394bd4906 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -833,25 +833,6 @@ operand (expressionP) 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) @@ -888,14 +869,14 @@ operand (expressionP) case 'x': case 'X': - if (flag_m68k_mri) + if (flag_m68k_mri || NUMBERS_WITH_SUFFIX) goto default_case; input_line_pointer++; integer_constant (16, expressionP); break; case 'b': - if (LOCAL_LABELS_FB && ! flag_m68k_mri && ! NUMBERS_WITH_SUFFIX) + 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 @@ -917,7 +898,7 @@ operand (expressionP) /* Fall through. */ case 'B': input_line_pointer++; - if (flag_m68k_mri) + if (flag_m68k_mri || NUMBERS_WITH_SUFFIX) goto default_case; integer_constant (2, expressionP); break; @@ -930,7 +911,9 @@ operand (expressionP) case '5': case '6': case '7': - integer_constant (flag_m68k_mri ? 0 : 8, expressionP); + integer_constant ((flag_m68k_mri || NUMBERS_WITH_SUFFIX) + ? 0 : 8, + expressionP); break; case 'f': @@ -980,7 +963,7 @@ operand (expressionP) case 'd': case 'D': - if (flag_m68k_mri) + if (flag_m68k_mri || NUMBERS_WITH_SUFFIX) { integer_constant (0, expressionP); break; diff --git a/gas/read.c b/gas/read.c index e8711663f62..c5108933c8f 100644 --- a/gas/read.c +++ b/gas/read.c @@ -2644,15 +2644,28 @@ s_rept (ignore) int ignore ATTRIBUTE_UNUSED; { int count; - sb one; - sb many; count = get_absolute_expression (); + do_repeat(count, "REPT", "ENDR"); +} + +/* This function provides a generic repeat block implementation. It allows + different directives to be used as the start/end keys. */ + +void +do_repeat (count, start, end) + int count; + const char *start; + const char *end; +{ + sb one; + sb many; + sb_new (&one); - if (! buffer_and_nest ("REPT", "ENDR", &one, get_line_sb)) + if (! buffer_and_nest (start, end, &one, get_line_sb)) { - as_bad (_("rept without endr")); + as_bad (_("%s without %s"), start, end); return; } @@ -2667,6 +2680,23 @@ s_rept (ignore) buffer_limit = input_scrub_next_buffer (&input_line_pointer); } +/* Skip to end of current repeat loop; EXTRA indicates how many additional + input buffers to skip. Assumes that conditionals preceding the loop end + are properly nested. + + This function makes it easier to implement a premature "break" out of the + loop. The EXTRA arg accounts for other buffers we might have inserted, + such as line substitutions. */ + +void +end_repeat (extra) + int extra; +{ + cond_exit_macro (macro_nest); + while (extra-- >= 0) + buffer_limit = input_scrub_next_buffer (&input_line_pointer); +} + /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then this is .equiv, and it is an error if the symbol is already defined. */ diff --git a/gas/read.h b/gas/read.h index 9d080bfb23c..571b59b58ab 100644 --- a/gas/read.h +++ b/gas/read.h @@ -116,6 +116,8 @@ extern void stabs_generate_asm_file PARAMS ((void)); extern void stabs_generate_asm_lineno PARAMS ((void)); extern void stabs_generate_asm_func PARAMS ((const char *, const char *)); extern void stabs_generate_asm_endfunc PARAMS ((const char *, const char *)); +extern void do_repeat PARAMS((int,const char *,const char *)); +extern void end_repeat PARAMS((int)); extern void generate_lineno_debug PARAMS ((void)); -- 2.30.2