Assembler Development Environment

Source: Internet
Author: User
Tags visual studio 2010

 

Introduction

These days, we have been studying underlying technologies, from Windows drivers to Windows kernels, and so on,

I became more interested in underlying technologies, but when I was studying WRK,

Insufficient understanding of memory management, registers, address bus, Data Bus, control bus, etc,

So I want to learn assembly program design more and more to improve my skills,

Since there have been projects under pressure in the company recently, it is really hard to look at the Compilation Program Design in the company,

So I had to come back to study at night, and I thought it was pretty good to compile and read it for a few nights.

Let's build a development environment today.

Development Environment combination

I will introduce four methods for developing assembler programs:

First, directly use the Edit command in the Dos environment to bring up the source code editing box,

After the source code is generated, you can use the masm compilation compiler provided by Microsoft to compile the source code,

After compilation, you can use the Linker connector to obtain the executable file,

This method is almost extinct now (of course it is still common to use the masm assembly compiler ),

Unless you really want to run the assembler in the DOS environment;

Second: simplify the first method;

Third: directly use the Masm for Windows integrated experimental environment. This development environment is very suitable for beginners of assembly languages,

This IDE is developed by some university teachers engaged in assembly program teaching to compile the learning and Experiment for beginners,

Therefore, it is easy to use and convenient. Here we can slightly recommend this IDE;

Fourth: compile, run, and debug the assembler Through Visual Studio, a powerful IDE,

As for Visual Studio, I will not introduce it much. Net has been used for so many years. To what extent is this powerful;

Method 1: Use Edit + MASM 5.0 compiler + Linker Connector

In fact, this method is very simple, but it is very troublesome, because it is simple and troublesome,

So I try to pass it up and then introduce it with a slight annotation,

Software preparation:

Requires an assembly compiler of MASM 5.0 or later

First, edit the Assembly source code:

In fact, you don't need to bother editing the source code as follows. Just take a notepad and you will be OK.

Run the cmd command

Enter the Edit command to bring up the compilation source code Edit box.

Enter the Assembly source code in the source code input box.

Save the edited Assembly source code to the xx. asm file.

Then compile and edit the Assembly source code.

In the Dos environment, enter the directory where the MASM 5.0 compilation compiler is located.

Then run masm.exe

You can see the [. ASM] mark from the above. This mark indicates that you need to enter the source program file name to compile here,

The default file extension is. asm, so you do not need to specify the extension of the file where the source program is located when compiling the. asm Assembly source program.

We will input the file where the compiled source program is located for compilation.

Press Enter after specifying the file path

The compiler prompts you to enter the name of the target file to compile. Since BoyXiao. asm has been specified at the beginning,

Therefore, the compiler automatically specifies the name of the target file as BoyXiao. obj. If no modification is made here,

The compiler outputs the default target file name BoyXiao. obj. Here, the name is not changed, so press Enter.

At this time, the system prompts you to enter the name of the list file. In fact, you do not need to let the compiler generate this LST file, so you do not need to enter it,

Press Enter.

At this time, the system prompts that you need to enter the name of the cross-reference file. Here, we do not want the compiler to generate this CRF file,

Therefore, you do not need to Enter it. Simply press Enter.

So far, the compilation source program has been compiled successfully,

The compiled result is that a BoyXiao. obj file is generated under my E: \ Tools \ MASM 5.0 directory.

The following figure shows how to connect the target file.

After compilation, we get a. obj target file, but obviously this is not an executable file,

Next we need to connect the target file to obtain an executable file.

Generally, you need to prepare a connector. Here I use the Linker connector provided by Microsoft, that is, LINK. EXE,

Go to the directory where the LINK. EXE file is located and run LINK. EXE directly.

Enter the name of the target file to be connected, which is BoyXiao. obj,

Because my BoyXiao. obj and Link.exe are in the same directory, you do not need to specify a path and directly give the. obj name,

Press Enter

Enter the name of the executable file to be generated. If you want to input the executable file to the specified directory,

You need to specify the directory. Otherwise, you only need to specify the name, and you can see that the name already has the default value: BOYXIAO. EXE

Here I select the default value, so press Enter.

Press Enter

Continue to prompt you to Enter the name of the image file. Here, you do not need to generate this file, so press Enter.

At this time, the system prompts you to enter the name of the library file. Because no subroutine is used in this program,

That is, no library file is called, so you can press Enter to process it.

Now, the connection to the target file is complete. The result is an EXE file.

Execute Assembler

In fact, there is no result in execution, because the assembly code above does not output any content, but only changes the values of several registers,

Naturally, no output is visible.

Method 2: Use Edit + MASM 5.0 compiler + Linker connector (Simplified Version)

This method is actually different from the first method, but it only uses a lot of default settings for compilers and connectors during compilation and connection.

Software preparation:

Same as the first method

Edit Assembly source code:

The same as the first method, you can directly use the text editor to edit it.

Compiled and edited Assembly source code

Directly go to the MASM. EXE file directory and use masm to compile the file in the specified path.

Note that you need to add ";" to the end of the directory.

InE: \ Tools \ MASM \ mam 5.0Directory generatedBoyXiao. objTarget File

Connect the target file

Similarly, directly go to the directory where the LINK. EXE file of the connector is located, and then directly connect to the specified target file using LINK.

Also note that ";" is added after the directory or file name.

You can see that the connection is successful and an executable file is generated. Of course, the running effect of this executable file is the same as that in the first method,

No output is visible.

Method 3: MASM For Windows integrated development environment

The two methods above seem very troublesome. If compilation requires connection, who has so much time to waste,

Therefore, the MASM for Windows integrated development environment described below is very advantageous,

Software preparation:

MASM for Windows integrated development environment, I am using version 2010, the size of 15.5 MB

Implement HelloWorld

Open the integrated development environment of MASM for Windows, find the sample program, and run it directly.

It can be seen that using this stuff is indeed much more convenient.

Method 4: Use Visual Studio to develop assembler programs

Software preparation:

Since Visual Studio is used for development, Visual Studio IDE is required,

Here, I am using Visual Studio 2010. Of course, both 2008 and 2005 are acceptable,

There are only some differences in some settings. Here, I will not differentiate them. If you are interested, you can go to Taobao online,

Then there is the Irvine package in <Intel assembly language programming>.

VS 2010 settings:

Create an empty project in VC ++ and name it Test

 

Custom VC ++ project construction rules

After VC ++ is set up to generate the custom item file, add a C ++ file. Note that the suffix is. asm.

Set Project Properties of the VC ++ Project

You need to add a library path. The library path here refers to the Irvine library in <Intel assembly language programming>

Set include path

Set the dependent library file and add Irvine32.lib

Set Project output

Set to generate the assembly code list and add the $ (ProjectName). lst attribute.

Hello World Program:

Run it directly.

Conclusion

It is a painstaking effort to introduce these four methods of assembler program development. In fact, these four methods are,

We don't have to master it all. We just need to find a suitable method for ourselves,

For example, For beginners, I think MASM For Windows IDE is very good,

Visual Studio is a good choice for systematic development, especially for Win32 Assembler programs.

 

Source: http://www.cnblogs.com/BoyXiao/archive/2010/11/06/1870397.html

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.