NASM 中 %rep 部分的标签 [英] Label in %rep section in NASM

查看:123
本文介绍了NASM 中 %rep 部分的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 %rep 预处理器指令,它创建一个预处理器循环.我想在其中声明标签,可能有一些连接,但我无法正确使用语法.

I have %rep preprocessor directive which creates a preprocessor loop. I would like to declare label in it, probably with some concatenation, but I cannot get the syntax right.

%assign i 0 
%rep    64 
   label_%i: ;this, of course, doesn't work
      inc rax    
%assign i i+1 
%endrep

那么如何强制 NASM 预处理器为每次迭代"生成 label_i?

So how to force NASM preprocessor to generate label_i for every "iteration"?

推荐答案

这可以通过使用 %+ 符号来完成.以下是文档的摘录:

This can be accomplished by using the %+ notation. Here's an excerpt from the documentation:

4.1.4 连接单行宏标记:%+

4.1.4 Concatenating Single Line Macro Tokens: %+

单行宏中的单个标记可以连接起来,以生成更长的令牌以供以后处理.这可能很有用,如果有几个类似的宏执行类似的功能.

Individual tokens in single line macros can be concatenated, to produce longer tokens for later processing. This can be useful if there are several similar macros that perform similar functions.

请注意 %+ 后需要一个空格,以便将其与多行宏中使用的语法 %+1 消除歧义.

Please note that a space is required after %+, in order to disambiguate it from the syntax %+1 used in multiline macros.

可以在此处找到有关预处理器中的此功能和其他功能的更多信息.

这篇关于NASM 中 %rep 部分的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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