News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

how to use next line when using macros?

Started by xandaz, December 13, 2020, 03:46:11 AM

Previous topic - Next topic

xandaz

   i had this code
mov hMainWindow,rv( CreateWindowEx,0,addr szClassName,\
addr szWindowName,WS_OVERLAPPEDWINDOW,eax,ebx,\
0,0,hInstance,0

Returns error missing right parentsis. How to overcome this? Thanks in advance

Biterider

mov hMainWindow,rv( CreateWindowEx,0,addr szClassName,\
addr szWindowName,WS_OVERLAPPEDWINDOW,eax,ebx,\
0,0,hInstance,0)

xandaz

  didn't work. i guess i'll keepusing the same Line. thanks anyway

Biterider

It assembles if you put the correct number of arguments in the CreateWindowEx call.

jj2007

Quote from: Biterider on December 13, 2020, 04:11:02 AM
It assembles if you put the correct number of arguments in the CreateWindowEx call.

Exactly.

mov hMainWindow,rv( CreateWindowEx,0,addr szClassName,\
addr szWindowName,WS_OVERLAPPEDWINDOW,eax,ebx,\
0,0,0,0,0,0)

HSE

Equations in Assembly: SmplMath

xandaz

  yeah i forgot windowWidth and height members but it's still not working.

Biterider

Check this snippet, and compare it with your code.

include \masm32\include\masm32rt.inc                   ;Plain Masm32

.data
szClassName db "MyName"
szWindowName db "MyClass"

.code
start proc
  local hMainWindow:HANDLE
 
  mov hMainWindow, rv(CreateWindowEx, 0, addr szClassName,\
    addr szWindowName, WS_OVERLAPPEDWINDOW, eax, ebx,\
    CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0)
  invoke ExitProcess, 0
start endp

end start


Biterider

xandaz


hutch--

The function form of MASM macros cannot be split across multiple lines. Use "invoke" and copy EAX or RAX (in 64 bit) to a named memory operand.

jj2007

Quote from: hutch-- on December 13, 2020, 12:40:09 PM
The function form of MASM macros cannot be split across multiple lines.

With rv(), it works fine:
include \masm32\include\masm32rt.inc
.code
start:
mov ebx, rv(CreateWindowEx, 0, chr$("classname"),\
chr$("WindowName"), WS_OVERLAPPEDWINDOW, eax, ebx,\
0,0,0,0,0,0)
print str$(ebx), " is zero, as expected"
exit
end start

hutch--

Tested your code and it fails.

  ; -----------------------------------------------------------------
  ; create the main window with the size and attributes defined above
  ; -----------------------------------------------------------------
;     invoke CreateWindowEx,WS_EX_LEFT or WS_EX_ACCEPTFILES,
;                           ADDR szClassName,
;                           ADDR szDisplayName,
;                           WS_OVERLAPPEDWINDOW,
;                           Wtx,Wty,Wwd,Wht,
;                           NULL,NULL,
;                           hInstance,NULL
;     mov hWnd,eax

    mov hWnd, rv(CreateWindowEx, 0, chr$("classname"),\
    chr$("WindowName"), WS_OVERLAPPEDWINDOW, Wtx, Wty,\
    Wwd,Wht,0,0,hInstance,0)



project.asm(162) : error A2157:missing right parenthesis
project.asm(163) : error A2008:syntax error : offset

There has been an error while assembling this project.

Press any key to continue . . .

jj2007


hutch--

Shame, I would like to be able to use it but I am stuck with using invoke. No big deal, just another line of code.

mov hWnd, eax

xandaz