News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

push macros for MASM

Started by Vortex, February 19, 2006, 12:52:46 PM

Previous topic - Next topic

Vortex

Hi friends,

Here is a set of macros simulating the push statement with extended capabilities :

push2 MACRO args:VARARG
   FOR p,<args>
      push p
   ENDM
ENDM

pop2 MACRO args:VARARG
   FOR p,<args>
      pop p
   ENDM
ENDM

pushREV MACRO p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20

   FOR arg,<p20,p19,p18,p17,p16,p15,p14,p13,p12,p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>

      IFNB <arg>
         push arg
      ENDIF
     
   ENDM

ENDM


Examples :
push2 eax,ebx,ecx,edx outputs the sequence :

push eax
push ebx
push ecx
push edx

pushREV eax,ebx,ecx,edx passes the parameters in reverse order simulating the STDCALL or C parameter passing convention :

push edx
push ecx
push ebx
push eax

Another example :
pushREV eax,OFFSET DlgName,NULL,OFFSET DlgProc,NULL

Here, you can find the POASM version of the these macros :

http://www.masmforum.com/simple/index.php?topic=3959.0

[attachment deleted by admin]

Ratch

Vortex,

     Wasn't this topic covered in thread http://www.masmforum.com/simple/index.php?topic=99.0 , during which the following code was submitted?  Ratch


;*******************************************************************************
; @ArgRev :  MACRO FUNCTION                                                    *
;                                                                              *
; Called by: @ArgRev(P1,P2:VARARG)                                             *
;                                                                              *
; Returns :  VARARG list in reverse order                                      *
;                                                                              *
; Coded by: Ratch                                                              *
;                                                                              *
;-------------------------------------------------------------------------------

@ArgRev MACRO P1,P2:VARARG
LOCAL TXT
TXT TEXTEQU <P1>

FOR ARG,<P2>
TXT CATSTR <ARG>,<!,>,TXT
ENDM

EXITM <TXT>
ENDM
;*******************************************************************************

PUSHIT MACRO P1:VARARG
FOR arg,<P1>
PUSH arg
ENDM
ENDM
;*******************************************************************************

RPUSHIT MACRO P1:VARARG
%PUSHIT @ArgRev(P1)
ENDM
;*******************************************************************************

INVOKIT MACRO P1:REQ,P2:VARARG
IFNB <P2>
RPUSHIT P2
ENDIF
CALL P1
ENDM

;*******************************************************************************

Vortex

Hi Ratch,

Your code looks fine, there is no any problem. Poasm required a set of extended push statements and this is what I tried to achieve. Later, I decided to translate the Poasm code to Masm.