A brief introduction of assembly language integrated development environment __ Assembly IDE

Source: Internet
Author: User
Tags win32

(i) editor (Editor)

Editor is indispensable, and now the editor is too much, in DOS you must have used the classic dos from the edit, or

Asmedit,wps and so on, but now the platform has moved to Windows, we have a richer choice, instead of the edit is Notepad, and even word,wps2000 such a powerful word processing tools, but choose them is not the best choice to write ASM, Because they are not designed specifically for the ASM design and do not fully meet our needs.

Now there are several more popular integrated ASM environment, one is asmstudio, people development, but only suitable for the ASM under DOS to write, support Win32asm has not seen, the second is Asmedit, is entirely written in ASM, compact support syntax highlighting functions, is also a good choice , now the highest voice I am afraid only Ketlio is developing the radasm, support Masm,tasm and FASM of the integration environment, there are automatic syntax prompts and other functions. In addition, there are editplus and UltraEdit for us to choose, which can be properly set to support syntax highlights, automatic filling, and shell execution functions, easy to use, How to automate the compilation of links in EditPlus see my previous article. Because of good Unicode support, it is recommended, and the only drawback is that you cannot implement WIN32API parameter hints and autofill. I'm using EditPlus. 2.01C. Feel good, recommended use.

(ii) compilers (compiler)

Now there are many kinds of compiler on the internet, more famous have masm,tasm,nasm,fasm,spasm,a86,gas,goasm etc, exactly what to choose as our compiler seems to be almost every beginner must ask questions. In fact, each compiler has advantages and disadvantages, what to choose, Depends on your actual needs. Here are some of the main:

1.MASM and Tasm

MASM is Microsoft's ASM compiler, TASM is the compiler giant Borland Company's products, the 5.0 version is now available on its home page for free download, I initially chose MASM reason is very simple, because most textbooks use him as a blueprint, In the DOS era of the room equipped with the basic is also MASM. In terms of DOS, but the lower version of the MASM is not the best, because Borland company introduced TASM,TASM fully compatible MASM, And because of the high speed of compiling and so the programmer's love. But in the domestic use more or masm.win32 under the TASM5.0 a bit powerless, this is because Tasm's head file and library is incomplete, and Borland also gave up the tasm of the continued development. Instead, MASM is constantly updated. , but also because Hutch for MASM made a masm32v.zip development package, which has a complete header file and library files, so Win32 under the use of MASM more and more people, become the mainstream.

2.NASM

NASM (Netwide Assembler) is a developing project designed to support a variety of platform file formats, such as the file formats used by UNIX and Linux, such as Elf,a.out, if you are writing ASM under the above platform, the best option is NASM, But NASM of course can also be used to write win32asm, Trouble and Tasm is the same, that is, the lack of header files and library file support, but if you are tired of the masm of the cumbersome and sometimes easy to produce ambiguity of the pseudo operator, try NASM syntax, I believe that will be harvested. NASM the link that generates obj can use ALink.

3.FASM

FASM (flat assembler) is a purely in assembly language, and the use of the development of the technology of the compiler, FASM the biggest advantage is that no additional link steps to generate the executable file directly, there is no trivial pseudo command, So the written code looks very clean. In addition, using FASM to write 16bit exe or COM may be a very good choice, simple and efficient. In addition, in the PE format import,export,resource, etc. are also unique.

4. Other

Other such as spasm,a86.

So if you're writing win32asm, MASM32 is still the best choice.

5. Resource Editor

WIn32 involves resources, you can use any compatible resource editor with RC (Resourcecompiler), such as a resource editor with Microsoft VC, or Borland resource Workshop. Most of the development package comes with the resource editor.

(III) Linker (linker)

Basically, the compiler for the above categories comes with the corresponding linker and resource Editor. Only NASM is an exception, and NASM with the use of a lot of linker, the most common application is ALink, the current version is 1.6.

attached: Use of MASM32 macro (MACRO)

If you have already used MASM, then let's take a look at what MASM is, MASM is the abbreviation of macro assembler, do you like to use macro? With macro can shorten the source code, simplify the writing of the program, easy to understand, and the MASM macro is still relatively powerful, Although some places are not intimate and concise, the following combination of the header file a brief introduction to a few commonly used macros.

1) M2M in Masm32 bag

MOV directive does not allow MOV mem1,mem,mem* representative address, you always

MOV Eax,mem

MOV mem1,eax

No, actually you can define a M2M macro, in order not to change the register content, using the stack

M2M MACRO M1, M2

Push M2

Pop M1

Endm

It's convenient to move from Mem to mem each time ....

2 return in C often encounter returns statements, in the WIN32ASM also often encountered in need of returned to the value of the place, let me to define the door to a returning statement:

return MACRO arg:=〈0〉

MOV Eax,arg

Ret

Endm

This makes it easy to use return TRUE or return false ...

But that's not the final answer. We can also optimize it based on the parameters returned, which is my optimized version.

return MACRO arg:=〈0〉

ifidni〈&arg〉,〈0〉

Sub Eax,eax

elseifidni〈&arg〉,〈1〉

XOR Eax,eax

inc EAX

ELSE

MOV Eax,arg

ENDIF

Ret

Endm

3 Ctext Sometimes you need to define some strings in ASM that may only be used once, and then you can use the Ctext macro

Ctext MACRO Y:vararg; This is a good macro

Local Sym

CONST segment

ifidni〈y〉,〈〉

SYM DB 0

ELSE

SYM DB y,0

ENDIF

CONST ends

Exitm〈offset sym〉

Endm

In this way you can use Inoke loadlibrary,ctext ("KERNEL32.dll") conveniently, especially when the code is longer without flipping over, defining data, and then offset * * * * ... Oh.

The other macro features below are basically consistent.

Dstext MACRO Name,text:vararg

. Data

Name DB text,0

. Code

Endm

The following macro is used to define the data in the code snippet, and note that if/SECTION:.TEXT,EWR otherwise read or write such data will be illegal.

Sztext MACRO Name,text:vararg

JMP @f

Name DB text,0

@@:

Endm

You can choose according to your needs.

4 $invoke macros, for inline coding, in C you must have seen GetModuleFileName (GetModuleHandle (0), &BUF), the statement in the ASM can still be implemented ... That is using the following $invoke macros:

$invoke Macro Fun:req,args:vararg

ifnb〈args〉

Invoke Fun,&args

ELSE

Invoke Fun

ENDIF

exitm〈eax〉

Endm

However, note the Register contention, such as the 3rd parameter used to EAX, then the first to second parameter can not use this embedded macro.

5) RGB and $rgb

In GDI programming, you often encounter RGB values as parameters, in order to simplify this process to define the following macros

RGB MACRO Red,green,blue

XOR Eax,eax

MOV Ah,blue

SHL eax,8

MOV Ah,green

MOV al,red

Endm

Then after the RGB macro with EAX as an RGB value parameter, this poem good idea, but not good enough, because occupy the extra line of code, in fact, we need just a grid of RGB values, so we have the following macro:

$RGB MACRO red:req, Green:req, Blue:req; This is better ...

Exitm% (red + 256 * (green + (256 * blue))

Endm

6) Pushm and POPM

In order to simplify the register and the stack and the design of the stack, very simple:

Pushm Macro Args:vararg

ifnb〈args〉

For arg,〈args〉

Push ARG

Endm

ELSE

. Err〈registers must be offerred!〉

ENDIF

Endm

POPM Macro Args:vararg

ifnb〈args〉

For arg,〈args〉

Pop arg

Endm

ELSE

. Err〈registers must be offerred!〉

ENDIF

Endm

7 data definition Rb,rw,rd,rq ....

Do you like the way it is? For example BUF db DUP (?) Is it very cumbersome to use the following macro can RB buf,260 is it simpler? At this time I like ...

RB Macro Label:req,count

ifnb〈count〉

Label DB &count dup (?)

ELSE

Label DB?

ENDIF

Endm

Similar to the RW,RD,RQ ... See my mac.h file for details.

8) Revargs The parameters in reverse order (special thx to LYB)

In the stdcall call mode is used in the reverse pressure into the parameters of the calling convention, MASM macros do not provide a mechanism to reverse the parameters, we have to write a macro byte.

Revargs MACRO Args:vararg

Local Target

Target textequ〈〉

Count=0

For arg,〈args〉

Target Catstr〈arg〉,〈!,〉,target

Count=count+1

Endm

IF Count GT 0

Target SUBSTR target,1, @SizeStr (%target)-1

EXITM Target

ENDIF

Endm

Used where you need to reverse-arrange the parameters.

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.