0

I expect I can access infinity macro argument in specified position in x64 machine.

For example

.macro myMacro infinityParam
  mov rax, \infinityParam[0]
  mov rbx, \infinityParam[1]
  mov rcx, \infinityParam[2]
.endm

So I can use that macro like this:

myMacro 5,9,8,6

rax will be 5. rbx will be 9. rcx will be 8.

So how do I make infinity argument in macro?

I'm sure it's possible because .int,.word, and another data declaration is supported to do it. Eg:

.word 2,7,4,9, ...

UPDATE: I have clue but it's not what I want.

.macro myMacroB param1, param2
  mov rax, \param1
  mov rbx, \param2
.endm

.macro myMacroA infParam
  myMacroB \infParam
.endm

_start:
  myMacroA "6,9"

As you see I can make infinity parameter with using string parameter,rax will be 6 and rbx will be 9.

But it's not what I want because myMacroB still finite param, I'm just giving clue.

Citra Dewi
  • 213
  • 3
  • 12
  • 1
    IIRC, you might need a recursive macro to get 1 arg at a time with a **variadic** macro. – Peter Cordes Jul 11 '22 at 22:23
  • 3
    [How to declare local variables in macro asm of gas like decalaring it in macro asm with %local in macro asm of nasm or local in macro asm of masm?](https://stackoverflow.com/q/34749659) shows an example of using `.macro foo arg1, tail:vararg` with recursion to pick apart a list of args. After checking the manual (https://sourceware.org/binutils/docs/as/Macro.html), I searched for `site:stackoverflow.com assembly gas ".macro" vararg` to find that example. You can grab args as many at a time as you want, e.g. in pairs with 2 args before the vararg. – Peter Cordes Jul 13 '22 at 05:58

0 Answers0