1
votes

In some x86 assembler dialects, one can place anonymous local labels using @@: and refer to them in jumps like jmp @F where @F refers to "next @@" and @B refers to "previous @@".

Here's a description from Microsoft I found while searching the web: Q33067: Anonymous Labels for Jump Instructions

I implemented support for anonymous local labels in NASM using its preprocessor's macro facilities, in my macro collection. All the way back to the first implementation on 2011-08-08 I had support for multi-step references. That is, jmp @FF refers to the second-next @@.

Today I got curious about the differences, if any, to MASM's handling of anonymous local labels. However, I couldn't find anything explicitly stating that multi-step references are supported by MASM. The link I gave only describes @F and @B. It doesn't specifically state anything to the effect that multi-step references are not supported either, though.

The only occurrence of @FF that I found on the web is in this FASM forum thread which discusses the possibility of adding multi-step @@ references. This seems to imply that, at least prior to this thread, FASM only supported single-step @@ references.

My question is, which assemblers do support multi-step references? Specifically, do MASM and TASM support them?

If you care for the context, I never use @B4 or @F4 except in the macro collection's tests and have as yet used @B3 or @F3 three times:

@B2 and @F2 are fairly common in my sources though.

2
I would take the lack of documentation of a feature to mean that it doesn't exist.Ross Ridge
Another source, jump to "Local Code Labels": bytepointer.com/masm/ml6.0b_quickhelp.htm Likewise only mentions @F and @B.ecm
Given that anonymous labels date back to an idea by Knuth and Knuth didn't have “multi-step references,” I suppose there won't be many. If you need so many labels that 0–9 won't cut it, try using a normal label instead.fuz

2 Answers

2
votes

GAS numbered local labels (as manual) are the same concept as MASM's @@: can be defined multiple times, f or b suffix to choose the closest one in that direction.

But instead of only @@, you have your choice of any number as the label name (typically single-digit), basically solving the same problem of being able to use labels in macros without hitting multiple-definition problems, and refer to a label that's not the immediately previous or next local label.

    jmp 3f
1:  nop
2:  jmp 4f
3:  jmp 1b
4:

See also ARM Assembly Local Labels for other examples.


NASM doesn't natively have either of these. .name labels are scoped to the previous non-dot label name, but for use in a macro it has special syntax for macro-local labels like %%foo:.

1
votes

Instead of leading at-sign @ €ASM uses leading fullstop . to specify localness of the label. Arbitrary number of different local labels can be defined and refered in one namespace block (PROC..ENDP) and they also can be refered from other blocks when the local label is concatenated with the name of its block. The number of steps (nesting depth) is not limited then, see https://euroassembler.eu/eadoc/#Namespace