This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GASP really obsolete?


Hi Nick,

On Thursday 13 June 2002 17:15, Nick Clifton wrote:
> Hi Frank,
>
> > > Can you use local labels ?  ie how about this:
> >
> > Unfortunately, not.
> > What about nesting of IFNZ/ELSE/ENDIF?
>
> Ah, OK.
>
> In that case please could you try out the following patch.  It adds a
> new feature to gas: "macro local labels".  These are local labels that
> are designed to work inside .macro constructs and which can be nested.
> (via a set of new pseudo ops).  Here is an example that uses them:
>
> 	.macro IFNZ val1, val2
> 	  .start_macro_labels
> 	  .push_macro_labels
>           cmpl \val1, \val2
>           jnz 1f
> 	  .stop_macro_labels
>         .endm
>
>         .macro ELSE
> 	  .start_macro_labels
>           jmp 2f
> 	  1:
> 	  .stop_macro_labels
>         .endm
>
>         .macro ENDIF
> 	  .start_macro_labels
>           1:
>           2:
> 	  .pop_macro_labels
> 	  .stop_macro_labels
>         .endm
>
> I think that this solution should be more efficient that the one that
> Ian was suggesting, since it does not affect normal symbol parsing.
> If it works, please let me know and I will check it into the binutils
> sources.

Thank you for your patch. But it still isn't the working solution.
Imagine the following case where we have a loop:

  REPEAT                  /* begin loop */
    IFZ varialbe_a, $0
      CONT                /* continue loop if a is zero */
    ENDIF
    IFZ variable_a, $1
      BREAK               /* abort loop if a is one */
    ENDIF
    /* do something with a */
  ENDR

We cannot implement REPEAT/CONT/BREAK/ENDR with {push/pop}_macro_labels
because we the IFZ statements had open an additional layer of local labels
which are unaccessible then from CONT/BREAK.

Frank
-- 
Frank Mehnert
## Dept. of Computer Science, Dresden University of Technology, Germany ##
## E-Mail: fm3@os.inf.tu-dresden.de    http://os.inf.tu-dresden.de/~fm3 ##


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]