This is the mail archive of the
mailing list for the binutils project.
Re: [gas] Label inside macro
- From: Erik Christiansen <dvalin at internode dot on dot net>
- To: binutils at sourceware dot org
- Date: Thu, 9 Jun 2011 20:00:25 +1000
- Subject: Re: [gas] Label inside macro
- References: <4DEFC6BD.firstname.lastname@example.org>
- Reply-to: dvalin at internode dot on dot net
On 08.06.11 21:00, Robert Uhl wrote:
> Is it possible to make the label only visible inside the macro?
> Or is it possible to use the parameter as a label inside the macro?
Both. Mike Frysinger's suggestion is the simplest intra-macro local
labelling method. (If you need to go backwards in the macro, use 1b,
Regarding the second question, here is a test macro which I wrote some
time ago. It demonstrates three ways to achieve local labelling in gas
macros, one of them using a parameter:
.macro unique_labels_x3 dest
LOCAL lbl ; Unique label is generated by the assembler.
; (It will start with "L", so is omitted from
; the symbol table. Can be put into symbol
lbl: ; table, using .global )
lbl_\@: ; Label generation from macro count.
ulx_\dest: ; Label generation from an argument.
unique_labels_x3 alpha ; Labels .LL0001 - 3, lbl_0 - 2, &
unique_labels_x3 beta ; ulx_alpha, ulx_beta, ulx_gamma
unique_labels_x3 gamma ; are generated.
All three worked well for me at the time.
Have fun with macros. They can be made to do more than is documented in
any detail, but it may be wise to archive a copy of the gas version
used , since I remember reading here that gas is intended to support gcc,
not those of us who play merry hell with macros, so there could
eventually be bitrot in dark corners, AIUI.
 But you're probably doing that already. ;-)
It is common sense to take a method and try it. If it fails, admit it
frankly and try another. But above all, try something.
- Franklin D. Roosevelt