Gas altmacro macro with a percent sign in a default parameter fails with “% operator needs absolute expression”

后端 未结 3 1244
执笔经年
执笔经年 2020-12-22 01:32

I want to create a macro like the following:

.altmacro

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

To be used as:



        
3条回答
  •  一生所求
    2020-12-22 01:49

    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>
    

提交回复
热议问题