How does MASM32 work ?

It is designed to plug into a computer that has other programming environments set up on it and this places some restrictions on the format. To avoid the problems associated with picking up the wrong link versions and wrong library directory, MASM32 works with specified paths to all of the binary files it needs to build the files.

In the source code, the paths to the library files are specified and in the batch files that are used by the editor to drive the build options, the paths of each binary file is specified as well.

Files from other sources usually do not build from MASM32 without some modification, usually placing the following MASM specific directives at the beginning of the source file will solve most of the problems. The other is to use the "include" & "includelib" syntax for the INCLUDE file and LIBRARIES so that their paths can be found.

`.386 ; forces 32 bit assembly`
`.model flat, stdcall ; memory model and calling convention`
`option casemap :none ; case sensitive code`

MASM32 uses its own version of "windows.inc". It is a file over 800k in size and has a very large set of equates and structures in it for 32 bit windows programming. It should always be put before the system include files and libraries.

EXAMPLE

`include \masm32\include\windows.inc ; always first`

`include \masm32\include\user32.inc ; system include`
`include \masm32\include\kernel32.inc ; file next`
`include \masm32\include\gdi32.inc`

`includelib \masm32\lib\user32.lib ; matching system`
`includelib \masm32\lib\kernel32.lib ; libraries after that`
`includelib \masm32\lib\gdi32.lib`

MASM32 version 8 starts with a set of prebuilt include files that are used to build matching libraries at installation so for each library, you use the include file that matches it. To find a function that you need depending on the reference material you are using, look in the system include file to see which file has the prototype for the function and include the file and the matching library.

Most of the common functions are in the three big system DLLs so if you look in,

`GDI32.INC ; graphics related functions`
`KERNEL32.INC ; operating system kernel functions`
`USER32.INC ; various user interface & other functions`

you will find most of the common functions.

For functions that are not in the main libraries, usually the Microsoft reference material specifies which library the function is in so if you look in the include file for that library, you will find the prototype for it. MASM32 also comes with a dedicated function to library tool called liblist.exe to help locate the function you require in the appropriate library.

There are two main reference sources for writing 32 bit assembler in Windows, for the assembler instructions and the general architecture of x86 series processors, the three (3) volume set of PDF files from Intel are the best available and are exhaustively documented in the PIII manual set. There is also a set of manuals for the PIV series of Intel processors.

The other is Microsoft reference material. The most common is a help file called "WIN32.HLP" which is now a little out of date but still useful. It is a help file of about 12 meg in size. Later information for Win98/se winME, win2k and XP are available in the PlatformSDK that can be obtained from Microsoft for the cost of the shipping.

The MSDN CD set are also useful if you have them available.