The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: korte on November 20, 2009, 03:48:34 PM

Title: for macro program
Post by: korte on November 20, 2009, 03:48:34 PM

I would like to define a macro.
Procedure generation.

first param: procedure name
second param: procedura arg number


defProc   proc1 , 3

want:

proc1 proc p1:DWORD, p2:DWORD, p3:DWORD



Title: Re: for macro program
Post by: dedndave on November 20, 2009, 04:19:29 PM
hi korte - welcome to the forum
i seem to recall macros like that in previous threads
try using the forum search tool - i bet you'll find just what you want
Title: Re: for macro program
Post by: korte on November 20, 2009, 05:07:08 PM
sorry dear dedndave, not found.

we tired:



proc_entry MACRO nam:REQ,nums
LOCAL cnt
lastproc equ _&nam

arg equ <>
      arg CATSTR arg,<nam >
        arg CATSTR arg,< proc >
    cnt=0
      FOR var,<nums>
if cnt gt 0
        arg CATSTR arg,<p>,cnt,<,:DWORD>
else
        arg CATSTR arg,<p>,cnt,<:DWORD>
endif
        cnt = cnt + 1
      ENDM

arg


endm

proc_entry myproc,10

Title: Re: for macro program
Post by: qWord on November 20, 2009, 05:30:19 PM
Quote from: korte on November 20, 2009, 03:48:34 PM
want:

proc1 proc p1:DWORD, p2:DWORD, p3:DWORD
with a few changes to your macro it works:

proc_entry MACRO nam:REQ,nums
LOCAL cnt
lastproc equ _&nam

arg TEXTEQU <>
    arg CATSTR arg,<nam >
    arg CATSTR arg,< proc >
    cnt=0
    WHILE cnt LT nums
if cnt gt 0
       arg CATSTR arg,<p>,%cnt+1,<,:DWORD>
else
     arg CATSTR arg,<p>,%cnt+1,<:DWORD>
endif
        cnt = cnt + 1
    ENDM

arg
endm
Title: Re: for macro program
Post by: korte on November 21, 2009, 06:43:42 AM

proc_entry MACRO nam:REQ,nums
LOCAL cnt
lastproc equ &nam

arg TEXTEQU <>
    arg CATSTR arg,<nam >
    arg CATSTR arg,< proc >
    cnt=0
    WHILE cnt LT nums
if cnt gt 0
       arg CATSTR arg,<,p>,%cnt+1,<:DWORD>
else
     arg CATSTR arg,<p>,%cnt+1,<:DWORD>
endif
        cnt = cnt + 1
    ENDM

arg
endm



thank you. Great
Title: Re: for macro program
Post by: Vortex on November 21, 2009, 10:10:32 AM
Hi korte,

Another procedure definition by assuming that all the parameters are DWORD by default :

DefProc procname,p1,p2,p3
Title: Re: for macro program
Post by: korte on November 24, 2009, 01:39:54 PM

Greetings, dear forum

Next "FOR" problem

work, but ugly



   FOR i, <16,17,18,19,20,21,22,23,24>
      mov [xxx+i],eax
   endm



Title: Re: for macro program
Post by: qWord on November 24, 2009, 02:53:05 PM
Quote from: korte on November 24, 2009, 01:39:54 PM
... ugly
That's a question of taste.

However, similarly to your previous problem:
    cnt=16
    WHILE cnt LT 25
mov [xxx+cnt],eax
        cnt = cnt + 1
    ENDM
Title: Re: for macro program
Post by: korte on November 24, 2009, 03:15:29 PM

I understand.
Thank you.
But not the specific case.

I would like to solve with "FOR"....
Title: Re: for macro program
Post by: jj2007 on November 24, 2009, 03:51:27 PM
What is the purpose?

include \masm32\include\masm32rt.inc

fm MACRO mem:REQ, args:VARARG
mov edx, mem
FOR arg, <args>
mov [edx+arg], eax
ENDM
ENDM

.data?
MyBuffer dd 20 dup(?)

.code
start:
fm offset MyBuffer, 16,17,18,19,20,21,22,23,24
exit ; short form of invoke ExitProcess, 0

end start