匿名本地标签 (@@):哪些汇编器支持多步引用,例如 @FF (second-next @@)? [英] Anonymous local labels (@@): Which assemblers support multi-step references such as @FF (second-next @@)?

查看:28
本文介绍了匿名本地标签 (@@):哪些汇编器支持多步引用,例如 @FF (second-next @@)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

解决方案

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:.

这篇关于匿名本地标签 (@@):哪些汇编器支持多步引用,例如 @FF (second-next @@)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆