The MASM Forum

Microsoft 64 bit MASM => MASM64 SDK => Topic started by: sinsi on February 11, 2019, 12:49:00 PM

Title: ptr$ macro
Post by: sinsi on February 11, 2019, 12:49:00 PM
Using more than one ptr$() with invoke does not work, since masm expands the ptr$ macro before the invoke macro.
Code: [Select]
local v1:qword,v2:dword
  invoke target,ptr$(v1),ptr$(v2)
  lea     rax, [rbp-68h]
  lea     rax, [rbp-6Ch]
  mov     rcx, rax
  mov     rdx, rax
  call    target

Any workaround?
Title: Re: ptr$ macro
Post by: hutch-- on February 11, 2019, 01:23:34 PM
Use registers for more than one. The macro is only a wrapper for "lea rax, var", mov vptr, rax".

I usually use it for single variables.

mov ptr1, ptr$(var1)
mov ptr2, ptr$(var2)
rcall MyFunc,ptr1,ptr2

With under 5 args, there is a more efficient way.

lea rcx, var1
lea rdx, var2
call MyFunc