News:

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

macro definition

Started by korte, March 05, 2007, 09:45:51 AM

Previous topic - Next topic

korte


I want to define C styile function with macro.

sample:

    FunctionName (param1,param2)

how to filter bracket ( )?

FunctionName macro p1,p2
  push p2
  push p1
  call myfunct
endm



sinsi

Just omit the brackets

FunctionName macro p1,p2
  push p2
  push p1
  call myfunct
endm

.code

...
FunctionName eax,OFFSET blah
...

This is the simplest form - there are many, many different ways (angle brackets, returning a value, ...)
Light travels faster than sound, that's why some people seem bright until you hear them.

korte

ok.

But I want to use bracket macro calling.

FunctionName (par1,par2)

I want C style  code

CreateWindow(p1,p2,p3,p4)

gfalen


FunctionName macro p1,p2
  push p2
  push p1
  call myfunct
  exitm <>
endm

sinsi

Quote from: korte on March 05, 2007, 11:05:14 AM
I want C style  code

So use C :bg

MASM won't let you use brackets without some fancy stuff...
And really, what's so good about brackets? just more typing
Light travels faster than sound, that's why some people seem bright until you hear them.

korte

I want to create portable code. ASM betwen C.
Define all procedure to macro.

Perfectly work but missing ugly bracket.

korte


sinsi

Quote from: korte on March 05, 2007, 11:46:01 AM
I want to create portable code. ASM betwen C.

I can see C being portable (with a lot of conditionals) but ASM (at least MASM/ML) is processor-specific - the Intel x86 instruction set.
AFAIK macros only work with MASM (Macro ASseMbler) but I could be wrong - I can (sort of) figure out C/C++ code but
couldn't write a "Hello World" program in C to save my mother...

Maybe you want to create .obj files in MASM to link with C?
Light travels faster than sound, that's why some people seem bright until you hear them.

Timbo

Greetings,

Unless I am mistaken, what korte wants to do is to allow his .asm modules to conditionally call C-style functions that are defined elsewhere (a la VS 2005 perhaps?) by the means of macro definition.  Maybe something like the following?
ifdef _DEBUG
DoSomethingCool MACRO p1, p2
push p2
push p1
call MyCoolFunc_d ;debug version of function
endm
else
DoSomethingCool MACRO p1, p2
push p2
push p1
call MyCoolFunc  ;release version
endm
endif
This is just an example.  Hope it helps.
Tim