Assembly Language Programming (V)

Source: Internet
Author: User
Tags function definition sort

Four, the bridge type method:

Bridge method is to use the characteristics of memory, read and write a number of instructions directly into the program, as a temporary temporary bridge, to change the function of this section program.
For example, when displaying, you want to provide a variety of changes, but do not want to reduce speed and add too many programs. The best way is to use the bridge method to fill in the required instructions at the same address.
The efficiency of the program is very helpful when the bridge method is used well and flexibly. It should be noted, however, that you can only use it in a readable and writable memory area, and you must never use this method if you want to make a "firmware", a program that is placed in read-only memory (ROM).
The following example is the bridge application for the screen display. First, the "material" of the bridge is set in the buffer, such as:
Cdspmod DB 88H; 8805 = MOV [Di],al
DB 30H; 3005 = XOR [Di],al
DB 08H; 0805 = OR [Di],al
DB 20H, and [Di],al
The cdspmod is the buffer, which has four data, which are different parts of the machine code, such as the semicolon after the note. Because the four sets of machine code are 05, no need to fill. = the right part, which is the corresponding instruction for the machine language.
The program part first sets up the function definition, uses one, the said variable application method, in sequence from 0 to 3 first load registers the register BX. According to BX value, the required machine code is loaded into the program.
10:clod:
11:mov AL,CDSPMOD[BX]; use BX to obtain the deposit code
12:mov cs:cdsp2[1],al; loading into cdsp2+1
13:CDSP:
14:sub si,si; data from 0
15:CDSP1:
16:LODSB; take information
17:CDSP2 LABEL BYTE, loading location
18:xor Es:[di],al, original code 26 30 05
19:inc DI; 30 parts to be changed
20:loop CDSP1
21:ret

Five, Pipeline method:

Industrial assembly line production operations, the need for extremely stringent specifications, the original devices were developed, unified sent to the assembly line.
The formula can be used in the same way, but unfortunately there is no ready-made and applicable example at hand, and the method has to be summarized as follows:
Set the process flow first, all can use this kind of production flow, all apply.
Then set the process of processing the "production line", that is, buffer. Because the data used on the assembly line need to be provided by the buffer.
The length of the buffer is determined by the process, and the data in the buffer is loaded by the original program that invokes the process.
Each calling program may, depending on individual conditions, place the required data in the buffer (in whole or in part). After the call, and then removed from the original buffer after the processed data.

Vi. corresponding Table method

The information that will be sorted out in a certain area in a fixed format, depending on a need. Every time you need it, you can immediately use it as an arrangement, which can be called the corresponding table.
The corresponding table is my favorite skill, the speed is very fast do not say, the modification is also extremely easy. In particular, I have always been informal, writing programs to make small mistakes. Since the use of the form of the control method, usually suitable for this form of the program, as long as the idea of the most ideal structure, a few instructions to the program finished.
The examples given in the appendix to the tabular method used in the glyph enlargement are introduced here.
Suppose you have a set of graphs that you want to zoom in on the screen one times. The general programmer to do this kind of problem, are in the register moved to remove, each character data, at least eight times to move the number, each time to use borrow as a conversion value. While converting, but also put into a 16-bit register, although you can use the loop to do, the time delay is quite large, the reader can refer to Appendix II for comparison.
Of course, the form to occupy space, in this case, if the 256B, take the foot is 512B.
So this technique can be said to be in exchange for time in space. In the first chapter of the third "efficiency" of the fourth law, we know that the keyboard input speed, determined by the speed of human operation, and people's response is far less than the computer, it should be the speed of people as the marginal value of time, try to save.
At present, what is involved is the display of time, everyone in front of the computer, expecting immediate results. Therefore, the display speed is not only fast, but the faster the better. Therefore, the aforementioned space-time exchange should be in the possible scope, depending on the actual marginal effect, to make trade-offs.
Now look at the data analysis, the following list of binary data, on the left side of the original graphic lattice, on the right side is magnified one-fold lattice:
The original lattice is magnified by about one times
00000001 00000000 00000011
00000010 00000000 00001100
00000011 00000000 00001111
..
01010101 00110011 00110011
..
11111111 11111111 11111111
Now there are two factors that are very obvious, first, no matter what dot matrix, enlarge the length plus one times, one character element has 256 kinds. The dot type is unchanged after amplification, but the number of characters is doubled to 512. Second, because half of the 512 enlarged after the same, there are still 256 kinds of representations.
As for the former or the latter, as the case may be.
After the decision, the definition in the buffer, with the original figure of the lattice data as the index value, you can use the indirect method, immediately gain amplification after the lattice.
In the production of the corresponding table, should develop good habits, according to the rules of the data, in the same length, fixed format input. This not only to the table of information can be a head, but also easy to input, debug, modify, a number.
If a form is:
MB Tbxxx DB 0,1,3,7,0fh,1fh,3fh,7fh,0ffh,2,6,0eh,1eh,3eh,7eh,0feh
This table looks far less obvious than the following table, the law:
MB Tbxxx DB 000h,001h,003h,007h,00fh,01fh,03fh,07fh
DB 0ffh,002h,006h,00eh,01eh,03eh,07eh,0feh
To engage in program writing, the pattern of thinking and pursuit, often with less effort. This little trick doesn't seem to have much effect. In fact, in the input, the rule-based structure can easily take advantage of existing functionality, or copy, or modify. More advantageous is to be able to see the meaning and correctness of the table at a glance, in the program debugging, often can save a lot of time.

Vii. Model Law

The so-called mode method, refers to in the process of program processing, analysis of its laws, in order to find a common "pattern." Use this pattern to design a programming unit to pursue maximum efficiency.
This mode can be represented by "concept", but the ideal expression method is still to be suitable for visual graphics. In other words, it is best to put the analytical patterns in a graphical representation and to understand and design the program.
This paper uses the commonly used function "sort" as an example to illustrate the application of pattern method and design it as a program.
Let's assume that the data structure that you want to sort is:
11 the length of each piece of data is fixed to one character.
The 12 data form is ASCII code, 16 decimal value, from 20H to 7EH.

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.