Author Topic: PrologueDef and EpilogueDef macros  (Read 611 times)

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
PrologueDef and EpilogueDef macros
« on: April 01, 2022, 02:45:25 AM »
Some of use may have used this:
Code: [Select]
  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.

Code: [Select]
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