News:

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

Using rv macro

Started by Matthew, April 25, 2012, 07:58:47 PM

Previous topic - Next topic

Matthew

Hello all, this is my first post here  :dance:

Is there a way to specify the parameters when using macros over multiple lines.

i.e


mov hWnd, rv(CreateWindowEx, NULL, addr szWindowClassName, addr szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL)


to something like;


mov hWnd, rv(CreateWindowEx,\
    NULL,\
    addr szWindowClassName,\
    addr szAppName,\
    WS_OVERLAPPEDWINDOW,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    NULL,\
    NULL,\
    hInst,\
    NULL)


I tried this but I get the following; error A2157: missing right parenthesis

I know I can do it by using the following but was just wondering if im missing something obvious.

fn CreateWindowEx,\
    NULL,\
    addr szWindowClassName,\
    addr szAppName,\
    WS_OVERLAPPEDWINDOW,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    NULL,\
    NULL,\
    hInst,\
    NULL)
mov hWnd, eax


Thanks for your time.



jj2007

The first one works with JWasm but not with any version of ML.EXE:
   mov ecx, rv(GetStdHandle,\
   STD_OUTPUT_HANDLE)

This one works in any case:
   invoke GetStdHandle,\
   STD_OUTPUT_HANDLE
   xchg eax, ebx ; assuming you need the result in a protected register

qWord

hi,
unfortunately, continuation of the line can't be used for function-like macros. However, you can also use the fnx macro that allows a syntax, which is similar to mov x,rv(...):
fnx hWnd=CreateWindowEx,\
    NULL,\
    addr szWindowClassName,\
    addr szAppName,\
    WS_OVERLAPPEDWINDOW,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    CW_USEDEFAULT,\
    NULL,\
    NULL,\
    hInst,\
    NULL


if you are not happy with the name fnx, you can redeclare the fn-macro:
fn macro args:VARARG
fnx args
endm
FPU in a trice: SmplMath
It's that simple!

jj2007

Strangely enough,
Let esi="Hello \
World"+CrLf$
Print esi
outputs Hello World, in spite of the tab before World. Apparently whitespace gets ignored.
Works with Masm but JWasm says Error A2090: Line too long after expansion

Caution with labels, by the way:
include \masm32\include\masm32rt.inc
.code
mystart: mov ebx, rv(GetTickCount)
sub ebx, rv(GetTickCount)
inkey str$(ebx), " for ebx"
exit
end mystart

Should be roughly zero, right? Test it... and see what Olly has to say :wink

Matthew


hutch--

Matthew,

You hit it right the first time, the macro parser in MASM is a bit "agricultural" in that it expects brackets to be matched on the line where the first one occurs. using either the "fn" or "fnx" macros does the job fine but you must write EAX to the memory operand you want it stored in as in fact you have done.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php