Assembler Development Environment

Source: Internet
Author: User

Introduction

Because these days have been studying underlying technologiesProgramTo learn about Windows Kernel and other technologies,

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 AssemblySource 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.

 

November 05, 2010

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.