News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

PrologueDef and EpilogueDef macros

Started by jj2007, April 01, 2022, 02:45:25 AM

Previous topic - Next topic

jj2007

Some of use may have used this:
  OPTION PROLOGUE:PrologueDef
  OPTION EPILOGUE:EpilogueDef


What if PrologueDef is a macro defined by ourselves? Testbed attached, pure Masm32 SDK. It behaves differently when assembled with MASM or the Watcom-based assemblers UAsm and AsmC.

MbProlog MACRO procname, flags, argbytes, localbytes, reglist, userparms
Local tmp$
  tmp$ CATSTR <** This is MbProlo for >, <procname>
  % echo tmp$
  MbProUsed=1
  mov eax, eax
  MbLocBytes=localbytes
  if localbytes or argbytes
if localbytes gt 8100
tmp$ CATSTR <*** warning: with >, %localbytes, < local bytes in &procname&, you might run into guard page problems. Use StackBuffer instead ***>
% echo tmp$
endif
push ebp
mov ebp, esp
if localbytes
add esp, -localbytes
endif
  endif
  ifnb <reglist>
for reg, reglist ; uses
MbProUsed=MbProUsed+4
push reg
endm
  endif
  EXITM %localbytes ; see Q94942
ENDM