Setting-up your MASM32 development environment
To start programming assembly language in windows, you need to first setup your development environment. Hopefully, this post may help you get started.
Getting an Assembler/Linker:
I previously posted the list of assemblers/linker and where you can get them, here.
For this post, since I use MASM most of the time, I will be walking you through getting the MASM32 SDK package, as it contain lots of useful procedures, include files, libraries, help files, examples, tools and more.. At the time of writing, the SDK version is 10, get it here. Work around your way to the download area, and get the latest installer package (SDK version 10 is around 4MB).
Be sure to read and understand the license: http://www.masm32.com/mlicence.htm
Then regularly check the devpinoy assembler forum, as we regularly post updates, so you'll get only the latest.
Once you're done downloading the Masm32 SDK10 installer, run install.exe and follow the direction. Make sure you're installing it in a directory with no space in directory name, like "c:\masm32", not "c:\Program Files\mask32" -- this is because the assembler/linker that is included in the package is an old one who will throw an error if found spaces in paths. I suggest don't change the default installation folder, which is in %root%\masm32, where %root% is the root of your selected drive (e.g., C:\)
The first thing the installer will tell you is about some faulty anti-virus scanner who often flag MASM32 as infected or potentially dangerous, while it is really safe:
"Some AV scanners do not have properly developed heuristic scanning and produce false positives when scanning very small files that are common in assembler programming. This is unfortunately a consequence of rushed commercial demand and lack of programming skills on the part of some AV vendors who attempt to impose a subset of the Microsoft Portable Executable specifications for 32 bit Windows executable files to cover some of their own technical shortcomings.
The MASM32 SDK has been built in a fully isolated environment from its original source code in text format and has been successfully installed on millions of computers around the world and it does not contain any viral infection or trojan code.
If you installation is damaged or interfered with by an installed AV scanner you may need to change the settings so that it does not delete or damage files in the MASM32 installation"
This is your hint to turn-off your anti-virus scanner for a while., only during installation. Don't worry, as I said, it is safe.
After installation, you'll get a nice greeting telling you that installation is successful:
That's it! You now have a complete MASM assembler environment. You can now turn your anti-virus program back on., and include your masm32 directory to exclusion, so it won't bother you much about false-positives.
Now let's see the important directories created for us by MASM32:
%masm32%\help
in here you can find lots of useful HELP files. If you're a beginner, do check asmintro.chm and opcodes.chm.
%masm32%\examples
in here you will find tons of examples. Do check them out everytime you need to learn how to get something done, you may find it in one of the examples.
%masm32%\include
in here, you will find include files mostly traslated from platform SDK for assembly programmers to include in their programs. It also contains masm32.inc include file that has all the defines and prototypes of MASM32 library. check masm32.chm for reference.
%masm32%\lib
in here, you'll find library files mostly taken from platform SDK for assembly programmers to include in their programs. It also contains masm32.lib file, see description for \include
\bin
in here are the binaries for assembling, linking, dump, debug etc.,
%masm32%\tutorial
has various tutorials for using the MASM32 package.
%masm32%\macros
in here are the macros for making your assembly programming experience quick, easy, fun and challenging.
Additional Downloads:
Below are recomended downloads to help you on your learning experiences about assembly programming on windows:
Windows Platform SDK - You must have this one (the latest is Windows 7 SDK Beta).
Visual C++ 2008 Express Edition - A free C++ IDE from Microsoft. You can set it up for MASM programming.
Iczelion's Tutorials - Most beginners find these tutorials useful and informative.
MASM 8.0 - If you want the latest MASM binary from microsoft, get this and replace the old ones in your masm32\bin (be sure to make a backup before you replace them)
Processor Manuals - I'm using Intel processor, both IA32 and IA64. -- you can google for the manual of your processor for a more precise link.
Art of Assembly eBook - Get a free copy of AoA!
OllyDBG - A great free debugger, this is a must download.
Trying your new environment:
Open Quick Editor that is included in MASM32 package. It is located in %masm32%\qeditor.exe. Or simply double-click the desktop shortcut that was created for you by MASM32 installer (if you allowed desktop shortcut creation during install).
In Quick Editor, type this simple program (it's a simple message box program, don't worry for now if you can't understand it, you'll get used to it later):
include \masm32\include\masm32rt.inc
.data
caption db "MASM32", 0
text db "It works!", 0
.code
start:
invoke MessageBox, 0, addr text, addr caption, MB_OK or MB_ICONINFORMATION
invoke ExitProcess, 0
end start
Save it (again to directory with no space in directory name - also, you filename should not contain space either) then go to "Project" and hit "Build All".
Quick editor will build the program for you!
Now run your program, click the "Program" menu, and hit "Run Program"
You should see a messagebox saying "It Works!":
Congratulation, you now have a working MASM32 installed in your system. Welcome to the club.
Next time, I'll walk you through more about Quick Editor, and how to setup an IDE for your assembly programming.
For now, it's already late. Until next time.
