I had been using the MASM32 SDK to get familiar with Microsoft Assembly. I thought I’d just share a couple basic things that helped me in the process.
Using Compiled Resources
The MASM editor that is installed from the SDK is the ‘Small Memory Footprint Editor Quick Editor’. Creating, compiling, linking and running MASM source code through this editor is a simple process. It definitely makes you miss some of the tools that Visual Studio provides though. One of which is the resource editor. The good news is that you can create resource files (.rc) in a Visual Studio C++ project, munge them a bit (remove the C++ ishness like included .h files, embed the #defines into the .rc rather than have a separate .h file and such things as that) and use them in the compilation process to produce your final binary.
To start the process you need to use a menu option in the editor to generate a ‘makeit.bat’ file. This file compiles the assembler files, compiles the .rc file and links everything for you. To generate this file use the editor menu option:
Script –> Create EXE makeit.bat
This assumes of course that you are creating an .exe type binary. If you’re creating something else then use the appropriate menu option. The file assumes that your .rc file is named rsrc.rc. So after you create your .rc file in Visual Studio then just copy it into your MASM project directory as the file name rsrc.rc.
The ‘makeit.bat’ file that is created looks like:
Generating Debug Info and Other Stuff
To cause MASM32 to also generate debug information when it compiles and links I simply edited this file and added command line parameters to both the compile (‘\masm32\bin\ml’ command line [/Zi /Zd /Zf]) and link step (‘mask32\bin\Link’ command line [/DEBUG /DEBUGTYPE:CV]) steps. Note that I also added command-line parameters to the compile command to generate browse information (/FR), a map file (/Fm), an assembled code listing (/Fl) and generate warnings (/W3).
Now when I compile I get my assembled code listing (.lst), browse information (.sbr) and debug information (.pdb) files.