This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: GASP really obsolete?
- From: Nick Clifton <nickc at cambridge dot redhat dot com>
- To: fm3 at os dot inf dot tu-dresden dot de
- Cc: binutils at sources dot redhat dot com
- Date: 12 Jun 2002 14:59:35 +0100
- Subject: Re: GASP really obsolete?
- References: <E17Hk9Z-0006nS-00@noys.inf.tu-dresden.de>
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