The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jj2007 on December 07, 2009, 10:49:55 AM

Title: void MACRO
Post by: jj2007 on December 07, 2009, 10:49:55 AM
52 of the macros in \masm32\macros\macros.asm return eax ("EXITM <eax>").
When using such a macro e.g. as mov eax, fsize(hFile), OllyDbg (http://www.ollydbg.de/version2.html) reveals that you create a pretty superfluous mov eax, eax.
Here is a very simple workaround:
void MACRO args
  % @CatStr(<;>, <args>)
ENDM


Usage (for example):
void fsize(hFile)
mov esi, alloc(eax)
Title: Re: void MACRO
Post by: dedndave on December 07, 2009, 10:55:56 AM
that is a much-needed macro, Jochen
i think it allows certain use of some of these macros that has otherwise been ellusive
Title: Re: void MACRO
Post by: jj2007 on December 07, 2009, 11:18:41 AM
Dave,
mov esi, alloc(fsize(0)) works, too, but I remember some situations where I simply could not get rid of the mov eax, eax
:bg
Title: Re: void MACRO
Post by: hutch-- on December 07, 2009, 12:01:47 PM
Ummmm,

How about,


mov pMem, alloc(bytesize)


No mov eax, eax there.  :bg

It is a cute macro though.
Title: Re: void MACRO
Post by: Slugsnack on December 07, 2009, 12:48:11 PM
Quote from: hutch-- on December 07, 2009, 12:01:47 PM
Ummmm,

How about,


mov pMem, alloc(bytesize)


No mov eax, eax there.  :bg

It is a cute macro though.
In some cases we don't want to move it anywhere. And just to have it stored in a register. And in the cases when we are content with having it left in EAX the assembler would generate an extra 'mov eax, eax' :/
Title: Re: void MACRO
Post by: hutch-- on December 07, 2009, 05:50:25 PM
thats easy to deal with, if you don't want the function format, don't use it. Just call the procedure directly or if you want a macro that works differently, write one. With the format of the macro returning EAX from the mACRo, it is in fact the author that is writing mov eax, eax, not the assembler or the macro.