Assembly language Programming (II.)

Source: Internet
Author: User
Tags bit set comparison table split

Iv. Module Segmentation

Since it is called a module, there is no problem of dividing or not. If a programmer starts with the concept of a module, thoroughly understand its nature, of course, know how to design, naturally there is no need for segmentation. Even so, in the process of making the program, it is often a letter horse to the reins, where to think, where to write. Therefore, the formation of the concept of modular segmentation, the actual work, has its own inevitable effect.
The reason for module segmentation is indefinite, which can be divided into the following several kinds:
1, in order to make the convenience, the program into modules, easy to maintain.
2, in order to work efficiency, or the need for speed, or space-saving programs, respectively, using different techniques to produce.
3, the programmer's ability to work, or working conditions to split.
4, because the function of the program classification, separate production, in order to flexible application.
Regardless of the reasons, before the segmentation module, we must first determine the target, a comprehensive understanding of the pattern of the program, and then to organize, classify, can be divided according to the category.
After classification, it is named after classification, so as to make it easy to remember and apply. The unified definition of the format is the key. Because a number of modules, mutual calls are very frequent, if the format can not be unified, the program often need to adjust, but increased the difficulty of using, outweigh the gains.
Second, each module must establish a general table, and to maintain the regular, must be with the actual users of the corresponding, do not be lazy. Every time you call, you need to revise the record, such as the number of times used, the program invoked, and so on.
If the size of the program production, the number of participants, the ideal is to be responsible for module management. Those who engage in this kind of work must be clear minded, responsive, and diligent in updating.
Before making a module partition, you should first prepare the. ref and. lst file, with a program abcd.asm, which is:
C:>m ABCD,,,;
M is the assembler, that is, the simplified name of Masm.exe, see chapter II, section Ii. Subsequent ",,,;" Indicates the need for. Obj,.lst and. CRF three files, and do not have to appear on the screen.
After the compilation is completed, the Cref.exe is used to generate Abcd.ref as follows:
C:>cref ABCD;
At this time, will abcd.lst and abcd.ref printed out, mutual control, first the program streamlined, sorted, and then split.
1, in the Abcd.ref file, each "title" from the Abcd.lst file, after the title, there are several groups of numbers, which with the #, indicating the source of the title, the rest of the call place. This title can be deleted if there is only a place to go, and no call is available. If the instruction before the title is JMP or RET, the program represented by this title is of no use and should be deleted.

2, if there are NOP instructions in the Abcd.lst file, they should be deleted unless they are intended to be arranged. If the jmp xxxx, it can be changed to JMP short xxxx.
If the program is not connected before XXXX, it can also be merged. In addition, the subroutine called by the command call, if it is called only once, is best to merge the script into the program, or subordinate it, so that it can be resolved.

3, the program streamlined and merged, then check the sections of the program, where the function of independent, should be divided first. After the split, and then check whether it calls other subroutines, if so, should be recorded first, this section of the program can be considered as "functional module."

4, where the subroutine called in the function module, if only for the module call, can be attached to the module, otherwise should be placed in the "common module."

5, the "main flow" of the program, most of the "Application module." Such application modules are extremely difficult to segment and are not necessary for segmentation.

6, after the split, should be detailed note, in order to spare.

V. Module characteristics

The so-called module characteristics, refers to each module in the design or segmentation of the factors considered at the beginning. Features include features, special requirements for efficiency, and details about modules that should be taken into focus when used.
Regardless of the target of module design, now that there is a module, it should be highly effective. Each module's segmentation, all has its inevitable factor, whether for the function, or in order to make convenient, the goal is pursues the efficiency. And each module has its own characteristics, to achieve efficiency requirements, should first understand the characteristics of the module.
The following is an example of the Chinese system in the previous section, which analyses the characteristics of each module one by one in detail as follows:
"Module One": The Chinese Processing System module-function module
1, keyboard interruption: Because the speed of people input is far less than the speed of computer processing, so, this interrupt program should be mainly to save space. In addition, the application of the keyboard to the flexibility to become the focus, it is advisable to use the "table" method, easy to modify, change.

2, show interrupt: Display speed is very important, this module should sacrifice space to fight for aging. In addition, the display of flexibility to large, where the size of the characters, location, attributes, etc., should be considered at once clear.
At present, the specifications of the monitor are many, incompatible with each other, generally more before the program loading, the first arrangements. In this module, particular attention should be paid to the different display programs, how to balance the speed of the operation.

3, Print interrupt: Printing also faces different kinds of machine interface problems, but because it does not involve speed, its skills belong to the setting and loading aspects.

4, communication interruption: communication needs to consider, is how to ensure the data transmission in the process of security, correctness and confidentiality.

"Module Two": Chinese inner Code module-Auxiliary module
Because the Cangjie code can be set up in the existing, as well as the arrangement of Chinese characters may be produced, should not be limited by the internal code. But the length of the Cangjie input code is indefinite, for the processing efficiency of the computer, we use four characters inside code, each character of the highest bit set to 1, in order to be different from English characters.
Internal code conversion should also consider speed, and to be able to bidirectional conversion, the program is not difficult to make, but the skills are not low.

"Module three": Chinese style Structure Module-interface module
Store the Chinese basic glyph structure, according to the input Cangjie code, obtains the basic message of the text structure, composes the zigzag.
Chinese words are very many, glyph structure planning is the key to success or failure, as long as each glyph add a few characters, space will be vicious expansion.
This module uses the technique of multi-layer structure, in which a lot of modules, space and speed, in order to be in a very small space, the completion of a large number of zigzag output, and flexible changes, complete worship module segmentation.

"Module Four": Glyph Analysis Module-Auxiliary module
All the shape size, type, pen change and location, etc., are completed in this module.
Glyph Analysis for the purpose of many changes, so the main function of the module in processing variables, should properly arrange the buffer to achieve efficiency requirements.

"Module Five": English Glyph Module-function module
English style and Chinese are different, so another module. Its words are less than Chinese, but they do not have any combination of functions.

"Module Six": Drawing module-function module
This program is the core of the glyph generator, and when the data of module four or five is obtained, the glyphs are plotted at high speed.
The key to the drawing program is calculated, although computing is the original function of the computer, if not additional "auxiliary calculator", the computational efficiency of the computer is greatly reduced.
Generally speaking, only on the screen drawing, or do glyph drawing, its scope is limited, and predictable, so you can use the "comparison table" or fast operation method, in exchange for display efficiency. When printing the output, the high precision operation method can be adopted.

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.