[The .org
directive将位置计数器增加到指定的偏移量,并用指定的值填充额外的字节。
.org
我想编写一个宏以执行类似的操作,但是具有更复杂的“填充”。喜欢:
.org 123, 1 @ Pads 1s until we reach address 123.
GAS抱怨此实现,因为@ Pads some_special_symbol until we reach address new_lc.
.macro my_pad new_lc
.if . < \new_lc
.4byte some_special_symbol
my_pad \new_lc
.endif
.endm
和the .if directive requires an absolute expression显然不是绝对的。
the dot symbol
到目前为止,我发现的唯一解决方法是更改宏的接口以进行重复计数,而不是结束地址。有更好的方法吗?
基于<instantiation>:2:5: error: expected absolute expression
.if . < 10
^
comment of @fuz
对于常量,也可以使用.macro my_pad new_lc
.if . - base < \new_lc
.4byte 0xdeadbeef
my_pad \new_lc
.endif
.endm
.data
base:
my_pad 100
实现宏而无需递归。