本文介绍了在默认参数百分号气体altmacro宏观失败"%运营商需要绝对EX pression"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建如下所示的宏:

I want to create a macro like the following:

.altmacro

.macro assert_eq a, b=%eax
    LOCAL ok
    #...
.endm

要作为:

assert_eq $1
assert_eq $1, %eax

我想 .altmacro 本地(我看到使用的另一种可能性 \\ @ ,但我想本地)。

I want .altmacro for LOCAL (I see the other possibility of using \@, but I want LOCAL).

但是当我尝试编译此我得到:

But when I try to compile this I get:

Error: % operator needs absolute expression

我猜测,这个问题是由一个事实,即 B =%EAX 正在尝试使用由 .altmacro :,
因为没有 .altmacro 我可以写这个没有问题。

I am guessing that this problem is created by the fact that b=%eax is attempting to use another feature enabled by .altmacro: Expression results as strings,since without .altmacro I could write this without problem.

如果这是真的,我怎么逃,对于我的宏来工作?如果不是,有什么不对我的code?

If this is true, how do I escape that for my macro to work? If not, what is wrong with my code?

奖金的问题:如何使用

Bonus question: how to use %?

GAS版本:52年2月23日

GAS version: 2.23.52

推荐答案

我遇到了,我想寄存器作为参数传递给需要使用.altmacro宏非常类似的问题。该工作定盘附上上述&lt寄存器;>和地点!之前%。因此,尝试改变你的宏为

I have run into a very similar problem where I wanted to pass registers as arguments to a macro that required the use .altmacro. The fix that worked was to enclose the registers in <> and place ! before %. So try changing your macro to be

.macro assert_eq a, b=<%eax>

如果你想打电话给你的宏与寄存器作为参数做

and if you ever want to call your macro with a register as an argument do

assert_eq <%eax>, <%ecx>

这篇关于在默认参数百分号气体altmacro宏观失败&QUOT;%运营商需要绝对EX pression&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 18:39