GASP really obsolete?

Nick Clifton nickc@cambridge.redhat.com
Wed Jun 12 06:59:00 GMT 2002


Hi Frank,

> I have to maintain GAS assembler files which contain a lot of GASP
> macros. The original author of these files wrote some macros to make 
> it easier to understand the assembler program. For instance, he was
> able to write such code:
> 
>   IFNZ variable_a, $0
>     call handle_case_a_not_null
>   ELSE
>     call handle_case_a_is_null
>   ENDIF
> 
> He implemented the IFNZ, ELSE and ENDIF using GASP macros:
> 
>   icount .ASSIGNA 0
>   ival   .ASSIGNA 0
>   MAXIF  .REG     (90)
> 
>   .MACRO IFNZ val1, val2
>     icount .ASSIGNA \&icount+1
>     ival   .ASSIGNA \&ival+1
>     cmpl   \val1, \val2
>     jnz    I\&icount
>     icount .ASSIGNA \&icount+1
>   .ENDM
> 
>   .MACRO ELSE
>     x1     .ASSIGNA \&ival-(\&ival/MAXIF*MAXIF)
>     ival   .ASSIGNA \&ival+1
>     x2     .ASSIGNA \&ival-(\&ival/MAXIF*MAXIF)
>     jmp    I\&x2
>     I\&x1:
>   .ENDM
> 
>   .MACRO ENDIF
>     x      .ASSIGNA \&ival-(\&ival/MAXIF*MAXIF)
>     I\&x:
>     ival   .ASSIGNA \&ival/MAXIF
>   .ENDM

Can you use local labels ?  ie how about this:

        .macro IFNZ val1, val2
          cmpl \val1, \val2
          jnz  1f
        .endm

        .macro ELSE
          jmp 2f
          1:
        .endm

        .macro ENDIF
          2:
        .endm

This assumes that you do not need the icount and ival counters outside
of the macros, but I think that it should work.

Cheers
        Nick



More information about the Binutils mailing list