The MASM Forum

General => The Laboratory => Topic started by: HSE on January 02, 2017, 02:29:14 AM

Title: invope macro
Post by: HSE on January 02, 2017, 02:29:14 AM
HI all!

This is a simple macro for nicer code. Perhaps there is a similar one, but I don't saw.

;######################################################
; A wrapper to invoke
; pushing registers before, and poping after

invope macro regis:REQ, params:VARARG
local count

argstr equ <invoke >
PushAll regis                                        ;ObjAsm32 macro
count = 0
FOR param1, <params>
if count eq 0
   argstr CATSTR argstr, <param1>
count = count+1
else
  argstr CATSTR argstr, <,param1>
endif
ENDM
argstr
PopAllRev regis      ;ObjAsm32 macro
endm


That allow to change:
push ecx
        invoke IsWindowVisible, [ecx].puntero
        pop ecx
        push eax
        push ecx
        invoke StrCat, addr [esi].salida, addr [esi].str_op
        pop ecx
        pop eax

by:

invope ecx, IsWindowVisible, [ecx].puntero
invope <eax, ecx>, StrCat, addr [esi].salida, addr [esi].str_op


Regards. HSE