The MASM Forum

General => The Campus => Topic started by: xandaz on December 13, 2020, 03:46:11 AM

Title: how to use next line when using macros?
Post by: xandaz on December 13, 2020, 03:46:11 AM
   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
Title: Re: how to use next line when using macros?
Post by: Biterider on December 13, 2020, 03:51:04 AM
mov hMainWindow,rv( CreateWindowEx,0,addr szClassName,\
addr szWindowName,WS_OVERLAPPEDWINDOW,eax,ebx,\
0,0,hInstance,0)
Title: Re: how to use next line when using macros?
Post by: xandaz on December 13, 2020, 04:00:50 AM
  didn't work. i guess i'll keepusing the same Line. thanks anyway
Title: Re: how to use next line when using macros?
Post by: Biterider on December 13, 2020, 04:11:02 AM
It assembles if you put the correct number of arguments in the CreateWindowEx call.
Title: Re: how to use next line when using macros?
Post by: jj2007 on December 13, 2020, 04:28:16 AM
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)
Title: Re: how to use next line when using macros?
Post by: HSE on December 13, 2020, 04:32:46 AM
Quote from: xandaz on December 13, 2020, 03:46:11 AM
Returns error missing right parentsis. How to overcome this?
:biggrin: :biggrin: :biggrin:
Title: Re: how to use next line when using macros?
Post by: xandaz on December 13, 2020, 04:40:01 AM
  yeah i forgot windowWidth and height members but it's still not working.
Title: Re: how to use next line when using macros?
Post by: Biterider on December 13, 2020, 04:47:47 AM
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
Title: Re: how to use next line when using macros?
Post by: xandaz on December 13, 2020, 07:17:20 AM
  Thanks.  :thumbsup:
Title: Re: how to use next line when using macros?
Post by: hutch-- on December 13, 2020, 12:40:09 PM
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.
Title: Re: how to use next line when using macros?
Post by: jj2007 on December 13, 2020, 07:56:57 PM
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
Title: Re: how to use next line when using macros?
Post by: hutch-- on December 13, 2020, 09:40:25 PM
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 . . .
Title: Re: how to use next line when using macros?
Post by: jj2007 on December 13, 2020, 09:50:04 PM
Sorry, you are right, it fails with MASM :sad:
Title: Re: how to use next line when using macros?
Post by: hutch-- on December 13, 2020, 09:58:05 PM
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
Title: Re: how to use next line when using macros?
Post by: xandaz on December 13, 2020, 11:30:58 PM
   Thanks guys. :thumbsup:
Title: Re: how to use next line when using macros?
Post by: HSE on December 14, 2020, 06:09:40 AM
Quote from: hutch-- on December 13, 2020, 09:40:25 PM
    mov hWnd, rv(CreateWindowEx, 0, chr$("classname"),\
    chr$("WindowName"), WS_OVERLAPPEDWINDOW, Wtx, Wty,\
    Wwd,Wht,0,0,hInstance,0)

You have to make something totally different with MASM :biggrin::   % mov hWnd, rv(CreateWindowEx, 0, chr$("classname"),\
    chr$("WindowName"), WS_OVERLAPPEDWINDOW, Wtx, Wty,\
    Wwd,Wht,0,0,hInstance,0)
Title: Re: how to use next line when using macros?
Post by: xandaz on December 14, 2020, 09:20:20 AM
   well... now i get it. It's totally different than i imagined. Thanks
Title: Re: how to use next line when using macros?
Post by: hutch-- on December 14, 2020, 10:16:04 AM
That will at least build but the return value is 0.
Title: Re: how to use next line when using macros?
Post by: HSE on December 14, 2020, 11:11:30 AM
Quote from: hutch-- on December 14, 2020, 10:16:04 AM
That will at least build ...

That is the idea  :thumbsup:
Title: Re: how to use next line when using macros?
Post by: hutch-- on December 14, 2020, 12:11:18 PM
Yeah but it won't run, returns 0, not the handle.
Title: Re: how to use next line when using macros?
Post by: jj2007 on December 14, 2020, 12:46:35 PM
It needs a bit of context, of course - see attachment. Builds fine with the old Masm 6.14 :cool:

  CASE WM_CREATE ; this message serves to initialise your application
% mov hEdit, rv(CreateWindowEx, WS_EX_CLIENTEDGE, chr$("edit"), NULL,\
  WS_CHILD or WS_VISIBLE or WS_BORDER or WS_VSCROLL or ES_MULTILINE,\
  9, 9, 500, 200, hWnd, 103, wcx.hInstance, NULL) ; we have added an edit control
Title: Re: how to use next line when using macros?
Post by: HSE on December 14, 2020, 11:20:42 PM
Quote from: hutch-- on December 14, 2020, 12:11:18 PM
Yeah but it won't run, returns 0, not the handle.
Yeah. CreateWindowEx have to fail because we don't registered the class we are requesting.
Title: Re: how to use next line when using macros?
Post by: hutch-- on December 15, 2020, 07:41:18 AM
My problem with these recent postings is that we have a member who started this post who is using MASM as supplied in the MASM32 SDK but keeps getting misleading information from folks who are using the Watcom derivatives which are not MASM compatible. I don't care what anyone uses but I object to misinformation that causes problems for people learning how to use MASM. We already have subforums for the Watcom derivatives, this is where support for the Watcom derivatives should be pointed.

This forum IS the MASM forum, not the Open Sauce Watcom derivatives forum and it is not a venue for alternative tools to use the incoming members for recruiting purposes, I would ask members who use the Watcom derivatives to no longer use the Campus for this purpose and will enforce it so that new members are not subjected to recruiting and misinformation.

The internet is a massive free venue that anyone can set up a web site and make it available to their user base. All you have to do is pay for a server, install the software, configure it for the tasks you have in mind, maintain it and moderate it to protect it from hackers, spammers and the like so it runs without the nuisance effects.

Please remember that this is a protected forum for beginners, not a recruiting ground for non MASM tools.
Title: Re: how to use next line when using macros?
Post by: deeR44 on December 28, 2020, 04:33:32 PM
Thank you, Hutch--,
There are so many people who ask questions having nothing whatsoever to do with MASM, that I go into this forum less frequently than I used to. Much less frequently.