The art of assembly language-basic understanding (i)

Source: Internet
Author: User
Tags definition

Section one application Tools

I. Understanding of the program

Writing a program is not difficult, but it is not easy to write a good program. This is like drawing, everyone can draw, and the picture may be different.
Want to be a good painter, first must have the ability of observation and analysis, facing the messy things, first sorted out the clue, find the theme. The outline is then outlined on the canvas, which is called "layout." Layout completed, according to the actual environment, decided to draw the "order". Order is a level of concept, scenery and color have a certain level, can not be arbitrary, think of where, where to draw.
After the observation, that is to start preparation, the brush, palette and other tools to put the appropriate, the main color to be displayed. Finally, select the appropriate brush, dip in color, and follow the results of the observation, painted on the canvas.
Painting rather heavy style, some individualistic artists, skills are not proficient, only because of the trend of the times or historical conditions, to create a unique style, to fame and benefits. The general painter is not, whether it is "meticulous" or "freehand brushwork" painting, relying on its skills and quality, can survive. As for the master of Art, the first heavy style, plus the quality, skills, can be famous, immortal.
The worst painter, no ability to observe, not to mention skills and style, in addition to according to other people's works plagiarism, imitation, create no valuable works. If the programmer is also so, can only follow other people's meaning, fill in the instructions, but a programmer just.
Under observation and analysis, the content of the desired performance is sorted into concrete steps, in computer terms, for "program Analysis", which is equivalent to "layout" in painting. The next thing is "process" production, or the order of the painting. Arrange the layers of the various programs to start writing programs, which is equivalent to starting a painting.
These concepts are very broad, not words can be finished. This book is intended only for the training of combinatorial language writing. If readers can make good use of the skills of combination language, and fully understand the work to be done, at least can meet the "fine brushwork" conditions. For a computer program, the current painting "fine brushwork" is worth more than "freehand brushwork" for the high.
Below, we should take the position of meticulous brushwork, to understand the application of combinatorial language. For oil painting or watercolor, color is equivalent to the program used "data", the palette is the use of data "registers", the brush is equal to "instructions", everything is ready, the so-called "painting" is "writing program."
A program is an executable procedure organized by a series of definitions and instructions, a file (. asm) must be processed by a compiler (Masm.exe) to convert the original file into a destination file (. obj), and then one or more of the destination files are joined (Link.exe) as the execution file (. EXE), or use exe2bin. EXE is made into a command file (. com) with a memory limit below 64KB.
Programmers should be familiar with every detail of the process before they can successfully complete the program writing.
The way the program is written is not fixed, it depends on the demand and application. But as with a picture, in the layout, the programmer should have all the ideas first, and then gradually implement. In order to improve efficiency, these steps need to be categorized. The result is the so-called module.
The good yu of the module determines the efficiency of program writing, modification and application. In writing, the requirements of the concept always, continuous. The modification should be convenient and flexible, and not be incorrectly clustered. And the application of the function to be complete, can be called independently.
According to the above conditions, the structure of the program can be broadly divided into:
1, the main program: the process of continuity, should be considered clearly, the details of the temporary side, first of all, to write out the big structure, so as not to ignore the end of the first. In the case of sufficient space, the large architecture should be a complete module, and in the overall concept, unified treatment.
This approach can be a great help for debugging and modifying the program. Because most of the changes and adjustments, the most impact on the function, must be the main program. If the main program is in the same module, it is easier to achieve the desired effect.

2, the Auxiliary program: The program is a number of details of the processing, you can use the ' call ' way to execute. In principle, the processing of details is often repeated in different situations, as the auxiliary program is quite advantageous. It should only be noted that the calling procedure, in order to be efficient, usually will need to process the parameters or data, via the registers or, if necessary, with a bumper load.
Since it is a program that can be shared by several programs, and such a program is an independent process, it should be tested separately, guaranteed to be correct.
In addition, the entrance of each auxiliary program, it is advisable to explain the use of the Register, and to be able to understand the eye.

3, subroutine: subroutine and auxiliary program is a little different, is to have the complete function. The so-called complete function, refers to the program can be independently executed, have a fixed function. When applied, the two are no different, but when writing, the subroutine should be considered carefully.

4, data file: Data files can also be considered as a static program, although not implemented, but is an indispensable material for execution. Data file design should pay attention to the use of space, such as the length of the data structure is the most efficient, it is best to ensure that the data starting point of the double, to save 16-bit bus execution speed.
In the application of buffers, should not arbitrarily set, often programmers set a buffer, and then found no need, and then want to delete the trouble big. So it should be arranged in advance so that it can be found and adjusted at any time. The arrangement is based on the circumstances of the use, some by the module, or by alphabetical order, or by adding a detailed annotation function and the program label used.

5, Application table: In this book, the fourth chapter Sixth section will introduce the application table function and the application way, this kind of table once design completes, very few need to revise, in order to work efficiency, independent becomes a file, has its own necessity.

In addition, the naming of various programs is best to be representative, to facilitate the application of the program can not be too large, or editing time consuming trouble, when the separation, you should pay attention to the marking of the Declaration and the arrangement of the issues. On disk, you should specialize in a subdirectory, and don't mix all the irrelevant programs.
The standard of the format is set out in section three or four of chapter II, and only one more point is added here. That is, the definition of each buffer and the use of the length should be equal, otherwise in the compilation or connection, prone to errors. When connected, sometimes there is not enough error message for the programmer to know the cause of the error. The most difficult to understand error is often related to the definition of the buffer, that is, the type of definition is inconsistent with the type used. Another situation is a change in the value of the paragraph, the remedy for the application, the temporary addition of a "predecessor definition."
The so-called "predecessor definition" means that when a register is a character, it should be added byte ptr, otherwise use WORD ptr to determine its value, you can guarantee security.
such as: MOV BYTE PTR Bbsdot1,al
In addition, each time the value of the segment changes, add a note:
Assume Cs:xxx,ds:yyy,es:zzz
This usage is entirely to the assembler "see", the program itself does not add any instructions.
Please refer to the relevant manuals for other requirements.

Ii. Understanding of the information

On the canvas, all the colors are made from red, blue, yellow, and white, understanding the change of color is the basic accomplishment of the painter. In the computer, all the data are composed of binary data, to write programs, must have a profound understanding of the characteristics of binary.
Most programmers, unaware of the magical uses of binary data, can quickly convert binary and decimal values. Otherwise, the binary value of the graph to understand the lattice arrangement, that's all.

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.