First Win32 Assembler Program development steps

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.