1

Is it possible to define procs where the name is derived from the inputs in a macro, using MASM 64? (ml64.exe)

Eg, something similar to below, where @(value) just places the 'value' in to the source.

proc_creator macro name, value
    foo_@(name) proc
        mov rax, value
        ret
    foo_@(name) endp
endm

proc_creator "example", 1
proc_creator "example2", 2

...

    call foo_example2
    ; use rax

So calling the macro twice defines two procs, foo_example and foo_example2.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
BJury
  • 2,526
  • 3
  • 16
  • 27

1 Answers1

2

Looks like the operator to use is & &, eg:

proc_creator macro name, value
    foo_&name& proc
        mov rax, value
        ret
    foo_&name& endp
endm

proc_creator "example", 1
proc_creator "example2", 2

...

    call foo_example2
    ; use rax

https://learn.microsoft.com/en-us/cpp/assembler/masm/operator-logical-and-masm?view=msvc-170

BJury
  • 2,526
  • 3
  • 16
  • 27