This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
PATCH repeat loop break
- To: binutils at sourceware dot cygnus dot com
- Subject: PATCH repeat loop break
- From: Timothy Wall <twall at domesolutions dot com>
- Date: Tue, 08 Feb 2000 12:28:32 -0500
- CC: nickc at redhat dot com
- Organization: Dome Solutions
This patch provides support for an implementation of a conditional break
out of an assembly repeat loop. It also allows the repeat start/end
tokens to be named something differently for compatibility purposes.
* gas/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.
* gas/read.h: Add prototypes for new functions.
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.13
diff -d -c -p -r1.13 read.c
*** read.c 2000/02/08 14:13:57 1.13
--- read.c 2000/02/08 17:20:17
*************** s_rept (ignore)
*** 2644,2658 ****
int ignore ATTRIBUTE_UNUSED;
{
int count;
- sb one;
- sb many;
count = get_absolute_expression ();
sb_new (&one);
! if (! buffer_and_nest ("REPT", "ENDR", &one, get_line_sb))
{
! as_bad (_("rept without endr"));
return;
}
--- 2644,2670 ----
int ignore ATTRIBUTE_UNUSED;
{
int count;
count = get_absolute_expression ();
+ do_repeat(count, "REPT", "ENDR");
+ }
+
+ /* generic repeat block implementation; allows different expressions 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 (start, end, &one, get_line_sb))
{
! as_bad (_("%s without %s"), start, end);
return;
}
*************** s_rept (ignore)
*** 2665,2670 ****
--- 2677,2699 ----
input_scrub_include_sb (&many, input_line_pointer);
sb_kill (&many);
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
Index: gas/read.h
===================================================================
RCS file: /cvs/src/src/gas/read.h,v
retrieving revision 1.3
diff -d -c -p -r1.3 read.h
*** read.h 2000/02/08 14:13:57 1.3
--- read.h 2000/02/08 17:20:17
*************** extern void stabs_generate_asm_file PARA
*** 116,121 ****
--- 116,123 ----
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));