) Create an Assembly Learning Environment

Source: Internet
Author: User

I believe that the compilation process is implemented on the Dos interface. inputting commands, compiling, connecting, and running are all mechanical operations. It is annoying. Of course, you can also choose some good integration environments. I went online to check others' comments and downloaded and tried it myself. RadASM is a good integration environment. However, it's too cumbersome. There are more than 100 M, and we don't need many features. And MASMPlus.

Here, I strongly recommend a software EditPlus, which is a small, flexible, and user-friendly text editor. It has many useful functions, such as unlimited UnDo/ReDo, but the biggest feature is that you can customize your own tools. Next, I will give you a reference using my own practices to create an environment and make your compilation and learning more comfortable.

First of all, of course you want to download an EditPlus. There are many online versions available in Chinese. Next, you need to download an assembly compiler. I chose Masm myself. I believe many people will choose this one. I am using masm 6.15, which can compile 32-bit and 16-bit. Here, we provide a web site of http://www.tup.tsinghua.edu.cn/Resource/tskj/017022-01.rar, an attachment to Intel assembly language programming (fourth edition) ([US] Kip R. Irvine. (This book is also recommended. You will find that compilation is also very interesting. Many books in China are boring. I have read half of them and do not know how to write a "Hello" program) there is already masm 6.15. Why do I propose to download this disc? It is just a few useful functions provided by it, such as DumpRegs, which can observe the register results at any time. Also, I am reading this book. You know, it is very painful to see the program running results. In fact, there are many macro calls and function calls written by others on the Internet. However, it is annoying for people like me to learn these things again. I just learned that what I need is just a few simple functions that can be input, output, and observed results.

Decompress the downloaded CD and install it on drive C by default. At this time, a C: \ Masm615 folder is added. Install EditPlus again (Note: I use the Chinese version). This software is more than 2 MB. Now we have all the things we need. You can set them.

Check out C: \ Masm615, which contains two. bat files. Make16.bat and make32.bat only provide some Parameter options during compilation. Copy them to your favorite location, such as D: \ My Batch. You may use these two files later. Do not delete them! It doesn't matter if you haven't downloaded the CD. I will write them out.
FileName: make16.bat The following is the file content. This line is not.

@ Echo off
Path c: \ Masm615; % PATH %
Set include = C: \ Masm615 \ INCLUDE; % INCLUDE %
Set lib = C: \ Masm615 \ LIB; % LIB %

Cls

ML/nologo-c-Fl-Zi % 1.asm
If errorlevel 1 goto terminate

LINK/nologo/CODEVIEW % 1, NUL, Irvine16;
If errorlevel 1 goto terminate

DIR % 1 .*

: Terminate

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>
FileName: make32.bat is the file content, this line is not

@ Echo off
Cls

Set path = C: \ Masm615; % PATH %
Set include = C: \ Masm615 \ INCLUDE; % INCLUDE %
Set lib = C: \ Masm615 \ LIB; % LIB %

ML-Zi-c-Fl-coff % 1.asm
If errorlevel 1 goto terminate

LINK32 % 1.obj irvine32.lib kernel32.lib/SUBSYSTEM: CONSOLE/DEBUG
If errorLevel 1 goto terminate

Dir % 1 .*

: Terminate

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>
I have deleted the original comment. You can modify it as needed. Don't be as rigid as you are, don't change directories, and change the compiler won't be used. Path, inclue, and lib are environment settings, and the directories are modified according to their actual conditions. % 1 is the first parameter to run this file. After ML Link, it is the compilation connection option. Depending on the options, you can compile 16-bit and 32-bit files.

With these two files, you can directly enter make16 file_name and make32 file_name when writing the source file of asm. You do not need to add the extension. asm. Of course, if you want the system to find your two files, you can set the corresponding environment variables. My computer (right-click, not double-click)-> properties-> advanced-> environment variables in the variable table click path, click Edit, add make16.bat in front, the directory name of make32.bat (for example, D: \ My batch. Do not delete the original one. If you use EditPlus, environment variables are not required.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>
Well, it's time to use EditPlus. Since I accidentally found this editor, I like it very much. Set the font first (I like it myself. I think the font Fixedsys, font Regular, and size 11 looks comfortable ), set the font in tool> parameter> General> font. There are other settings, as you like.

Choose tool> parameter> File> Settings and syntax, press the Add button, write asm in the description, write asm in the extension, and click associate current file type. Then, double-click. asm file to open EditPlus directly. You can also set tabs/indentation. I set the tabs and indentation to 8 spaces. You can also set a template for asm text.

Now you can use EditPlus to write the asm file. However, if you find anything unsatisfactory, there is no error. That is, the keywords of the Assembly statements do not have syntax coloring, A good editor usually uses different colors to differentiate different keywords. Well, now we use EditPlus, Which is syntax coloring. In this case, you need a syntax file suffixed with. stx. You can download it online, but it is too bad to download it online. Many of them do not conform to your habits. Do it yourself. I will provide you with a syntax file template named asm. stx. The content is as follows:

# TITLE = ASM
; This file is required for EditPlus to run correctly.

# DELIMITER =, () {} []-+ */= ~! & | <>? :
# QUOTATION1 ='
# QUOTATION2 ="
# CONTINUE_QUOTE = n
# LINECOMMENT =;
# ESCAPE = \
# CASE = n
# PREFIX1 =
# PREFIX2 =
# PREFIX3 =
# PREFIX4 =
# PREFIX5 =
# SUFFIX1 =
# SUFFIX2 =
# SUFFIX3 =
# SUFFIX4 =
# SUFFIX5 =
# HTML_EMBEDDED =
# SCRIPT_BEGIN =
# SCRIPT_END =
# HEREDOC =
# AUTOCASE =
# NUMBER_PATTERN = asm
# SPECIAL_STX = asm

# KEYWORD = Instruction Set
Mov
Add

# KEYWORD = Register
Ax
Eax

# KEYWORD = MASM Reserved words
Assume
Db
Byte
. Code
. Data

# KEYWORD = User-defined Functions
DumpRegs

#
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>
Among them, I divide the keywords into four categories: Instruction Set (Instruction Set), Register (Register name), Masm Reserved words (Reserved words of the Masm assembler ), user-defined Functions (the name of the function defined by myself), how is the syntax file defined? See help. But first you should know a few # CASE = n, which is CASE insensitive. If you change it to y, It is sensitive. You should know that assembly is CASE insensitive by default. # SPECIAL_STX = asm is the extension. This syntax file is used when your file type is. asm.
# LINECOMMENT =; starts. As you can see, the content in the keywords I gave you is very small. It seems that the command set only gives mov and add two. But don't worry. You can add these items on your own. When you add these items, you have a line. Many of the syntax files on the Internet are poor, not because they give too few things, but too many things. Of course, you can also define your own keywords, starting with # KEYWORD = NAME. You can refer to the cpp. stx format in the EditPlus directory.

How to use these syntax files? Choose tools> parameters> files> Settings and syntax file type asm (if this file type is not available, add it by yourself ). In the syntax file, select asm. path and name of stx. After selection, D: \ Program Files \ EditPlus 2 \ asm appears in the syntax file. stx text (usually put the syntax file back into the EditPlus directory to avoid missing), In the syntax coloring option, you can select the color of the keyword, in the future, the keywords you define will be different in different colors. (You also like the color settings, as long as you look comfortable, but we recommend that you do not have too many colors)

There are few words defined in the above syntax file. For example, Instruction Set is mov, and add won't even color sub. In this case, you can open the original syntax file, add sub, and save it. Choose document> refresh STX/ACP, And the sub is colored. When you write more programs and add new words at any time, Your syntax files are gradually improved. It doesn't matter if you start with less. You must change it to your satisfaction.

You can also associate the inc file, and select asm. stx as the syntax file.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>
Next, we will introduce another powerful feature of EditPlus, that is, to define your own tools.
Choose tool> parameter> tool> User press add tool> program press compile 32bit in the menu text, and select D in the command field: \ My batch \ make32.bat (started. bat file), select the text name (no extension) for the parameter, and $ (FileNameNoExt) will be added. Select the file directory at the start directory, and $ (FileDir) will be added ). You are sure to exit the dialog box. You can see that the tool menu has more menu items than compile 32bit Ctrl + 1. Then you can choose this menu item or press Ctrl + 1 to compile your file directly.
The above is to compile the 32bit asm file. Of course you can add the menu item compile 16bit in the same way to compile the 16bit asm file.

Next I will give you a run. bat file.

@ Echo off
If not exist extension 1.exe (
@ Echo No find the program extension 1.exe
Goto end)
Secrets 1.exe
: End

Add the menu item run in the same way. When you write the asm file later, Ctrl + 1 indicates compilation, and Ctrl + 2 indicates running. (Note: menu items can be moved up or down. Generally, the most common menu items are put in the most aspect.

As mentioned above, it is annoying to open a syntax file at any time. You can add a menu item edit asm. stx, where the command is c: \ windows \ system32 \ notepad.exe and the parameter is "D: \ Program Files \ EditPlus 2 \ asm. stx ", so that you can press Ctrl + 3 to directly use NotePad to modify asm. stx is very useful.

Ascii tables are often used when writing an assembly. You can also write a program to display the Ascii table and run the program by adding menu items. Press Ctrl + 4 to run it.
A c ++ program is provided to show the text. Although it is very simple, it is very convenient to display the text in the console window.
// ShowText. cpp

# Include <fstream>
# Include <string>
# Include <iostream>
Using namespace std;

Int main (int argc, char * argv [])
{
Char c;
Ifstream file_in (argv [1]);

If (argc <2)
Return 1;

If (file_in.fail ())
Cout <"Not find this file." <endl;

While (! File_in.fail ())
{
File_in.get (c );
Cout <c;
}

Return 0;
}
// >>>>>>>>>>>>>>>>>>>>>>>>>
Ascii.txt is an Ascii table.
The Table Of Ascii

0 1 2 3 4 5 6 7 8 9 A B C D E F

0 NL SOH STX ETX EDT ENQ ACK BEL BS TAB LNF VT FF CR SO SI

1 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN BM SUB ESC FS GS RS US

2 SPC! "# $ % & '() * + ,-./

3 0 1 2 3 4 5 6 7 8 9:; <=>?

4 @ A B C D E F G H I J K L M N O

5 p q r s t u v w x y z [\] ^ _

6'a B c d e f g h I j k l m n o

7 p q r s t u v w x y z {| }~

Then, add the Show Ascii command for a single dish. The command is the directory name \ ShowText, and the parameter is "directory \ Ascii.txt" to display the Ascii table at any time. You can also add menu items to add your help files, or add a calculator that comes with windows to convert values. Very convenient.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>
In the above example, we will explore the EditPlus function later. You can use it to compile the C ++/C/Java/C # program, as long as you have set it. Good editor.

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.