The MASM Forum

General => The Campus => Topic started by: Mondragon on June 10, 2017, 07:18:57 PM

Title: Hi All
Post by: Mondragon on June 10, 2017, 07:18:57 PM
Hello all, I don't want to make a scene but the instructions here are very clear about the spam issue and to make a posting so the account doesn't get deleted. Well, I'm human, I promise!

MASM has been the first assembly language I've learned because I learned by incorporating it into a few "C++" (I actually just use C but it's called VC++ in VS) programs. Been doing extern "C" and then linking in .asm files.

I'm going to go looking for some good newbie guides, but while I'm here, I might as well ask... Anyone have any tips on learning how to call up Win32 API funcs in ASM? I think my main question here is, must you include the Win32 header file in the actual .asm file or is it sufficient to include it in the C++ file that uses the .asm code? Thanks.

Title: Re: Hi All
Post by: Vortex on June 10, 2017, 07:53:28 PM
Hello,

Welcome to the forum. I can recommend you to start with Iczelion's Win32 Assembly Tutorials (https://win32assembly.programminghorizon.com/tutorials.html)
Title: Re: Hi All
Post by: felipe on June 11, 2017, 01:31:20 AM
Quote from: Mondragon on June 10, 2017, 07:18:57 PM
I think my main question here is, must you include the Win32 header file in the actual .asm file or is it sufficient to include it in the C++ file that uses the .asm code? Thanks.

Welcome to the forum. I don't know about c++, but i recommend you the use of the masm32 sdk, comes with all the include and lib files you will almost need. So you can do assembly programming and forget about c++.  :biggrin:
Title: Re: Hi All
Post by: aw27 on June 11, 2017, 04:01:42 AM
Quote from: Mondragon on June 10, 2017, 07:18:57 PM
have any tips on learning how to call up Win32 API funcs in ASM?
It is easier than you think, have a look at my article (https://www.codeproject.com/Articles/1182676/Need-for-Speed-Cplusplus-versus-Assembly-Language) and download the sources.

PS: Welcome on board!
Title: Re: Hi All
Post by: hutch-- on June 11, 2017, 04:37:50 AM
Mondragon,

The 32 bit version of MASM requires prototypes if you want to use its higher level notation. You can call API functions with PUSH/CALL notation but in most instances you get no advantage and its harder to read and write. You need both the libraries built for MASM and the include files. Current version of 32 bit ML.EXE (MASM) dates 2017 so its up to date but still as bad mannered as MASM always was.

Link at the top right of the page will get you a working 32 bit environment but you will have to provide the help files from Intel and Microsoft. You cannot use C header files with MASM.
Title: Re: Hi All
Post by: Mondragon on June 11, 2017, 04:43:29 AM
Great thanks for the resources guys. I'm installing the SDK now and also going to read thru the Code Project article.
Title: Re: Hi All
Post by: aw27 on June 11, 2017, 05:27:48 AM
Quote from: Mondragon on June 11, 2017, 04:43:29 AM
Great thanks for the resources guys. I'm installing the SDK now and also going to read thru the Code Project article.

Final note: You must not link with the libraries of the SDK, or any other libraries, from your MASM project. The reason is that the C++ linker will do the linkage for the whole project. In the MASM just put the prototypes for the external functions or rely on the include files of the SDK.

Title: Re: Hi All
Post by: jj2007 on June 11, 2017, 09:38:44 AM
To get you started:include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start


\masm32\include\masm32rt.inc is a text file, you can open it in qEditor or Notepad.
It contains the frequently used libraries. If you need something more exotic, one line does the job:uselib whatever

Have fun :biggrin: