1. Download and install the MASM, download the Nmake.exe tool, and place the Namake.exe under the bin of the MASM installation directory.
2. Write a batch file for setting environment variables Var.bat (put to the MASM root directory) The contents of the file are as follows:
@echo off
REM Modify the following MASM32DIR environment variables according to the installation directory of the MASM32 software package!
Set Masm32dir=d:\masm32
Set include=%masm32dir%\include;%include%
Set lib=%masm32dir%\lib;%lib%
Set path=%masm32dir%\bin;%masm32dir%;%path%
Set masm32dir=
echo on
3. Each time a new command-line console is opened, it is necessary to perform a var.bat (otherwise the console will not find commands such as Masm,link,nmake), and the effort is to add the environment variable to the user variable, or to the system variable.
4. Use the editor to write an. asm file, switch to the appropriate directory at the command prompt, compile and link a Win32 assembler with MASM commands commonly used by the source program are:
ML/C/coff Xx.asm
Link/subsystem:windows xx.obj yy.lib zz.res (plain PE file)
Link/subsystem:console xx.obj yy.lib zz.res (console file)
Link/subsystem:windows/dll/def:aa.def xx.obj yy.lib zz.res (DLL file)
4. Obviously using link is more complex, we can write a makefile in advance and then link it by using the NMAKE tool.
Makefile the following:
EXE = Test.exe #指定输出文件
OBJS = test.obj# Required target file
RES = resource file required by test.res#
Link_flag =/subsystem:windows# connection option
Ml_flag =/c/coff# Compilation option
$ (EXE): $ (OBJS) $ (RES)
Link $ (Link_flag) $ (OBJS) $ (RES)
. Asm.obj:
ML $ (ml_flag) $<
. Rc.res:
RC $<
Clean
Del *.obj
Del *.res
Then switch to the appropriate file directory to use NMAKE.
5. The steps to be summed up are:
Write your own program code--Modify the makefile-----var.bat command prompt to run the MASM compilation-->nmake
The. exe file is generated.