Chapter 2 Preparation
First system
First, the choice of system
Only because of the truly understanding of people, the results of superstitious name have made IBM PC / AT a market. In order to find computer popularization applications, we only make further analysis and descriptions for IBM PC / AT and its compatible systems. Although the microcomputer using the 80486 CPU has been published, I personally think that it is not compliant with the efficiency rules with its cost and function. At the position of art work, the value is high, and there is no absolute relationship with the materials used. What's more, we must prove that using the combined language production skills, it is possible to maximize the maximum marginal benefits of micro-computers. Therefore, this book is only 8088 CPU instructions to be discussed. As for what models, it is not within the scope of this book.
Second, catalog and disk
Assuming the reader is an experienced programmer, and the computer is IBM PC / XT / AT. At the beginning of the production program, it should first prepare the system. That is, the so-called "Want to do something, you must first make a tool", if you fail to note the details mentioned below, only one, two programs can be copened. The workload is large, the program is gradually increased, not some programs can't find, that is, I can't find it. The result is an upset, the horse and tiger, and then write one, and reluctantly deal with it. The hard disk space is large, and it should be relatively relative. First, the classification and application of the catalog and subdirectories should be properly planned. Otherwise, whenever you want a file, there are often the sigh of the sea. Otherwise, when the modification is modified, if you put different versions together, you will definitely Zhang Guan Li Dai, the wrong is. Each program should have its own directory, and each differential file should have different subdites, which can be clearly distinguished and the application. The most efficient way is that in each subdirectory, the number of files should not be too much, and only the program required under the same work item. Once the hard disk is broken, all storage materials will be put into water. For safety, you must back up with a flop. It is best to copy once a day, although it is replicated, it is quite troubles, but in case of being destroyed, that loss is an estimate. The best way is to make a special copy tool, generally used .bat application, every day, just execute once.
Third, the application tool
The programwriting is to control the operation of the computer, and the application tool is to convert the concepts and understanding of the programmaker into the instructions that can be performed continuously. Therefore, although there are many application tools on the market, they are not necessarily helpful. Severalings are listed below, as long as it is easy to use, absolutely enough.
Program Writing: Edlin, PE II, WS, etc.
Program compilation: Masm.exe Early (1.25) version allows more "external headings", ie External Label, but this version is limited to 8088 instructions, which is preferably a large-scale process. 4.0 Previous versions, at the beginning of the file, you can use .xcref to generate the address of the title and buffer. However, the later version will have an error and cannot be used again.
Program connection: Link.exe's early versions are some regulations for segment public 'xxxx', but after 3.0, in addition to both Code and DATA, other uses of Byte and Word are useless.
Program detection: DEBUG.EXE or SYMDEB.EXE and MAPSYM.EXE are the kits, and must be available. It has the advantage that during the detection, the title name in the original path can be used, and "breakpoint", etc., the detection is convenient, and the function is strong. System processing: PCTools.exe is a useful tool under DOS, which can be used as file management, or directly modify programcode. In addition, Ll.exe or Xtalk.exe or the like can be used when connecting. In particular, system programs are detected, often need to be used as a monitor with another microcomputer.
These tools should be put in the / DOS subdirectory and must be in the automatic execution of the system (Autoexec.bat), first set the priority channel (PATH) such as:
1: Path = / dos; is, whether in which subdirectory is in, the aforementioned tool can be used.
Fourth, simplify the name
The aforementioned various tools, frequent use during program detection, for application convenience, if you can enter some characters less, not only saves time, but also avoids errors. Under the inertial reaction, the user is concentrated, thinking about other details. The simplified name is the simplest method, it is best to use only one letter, due to the equal length, the file name later, you can use the "F3" "copy uplink" function provided by the system without having to enter.
It is changed to E.COM MAM.EXE to change to m.exe debug.exe to change to D.EXE Symdeb.exe to change to S.EXE, for example: after completing a program To assemble, as long as the first letter can be changed. C: /> e myfile.ASM (character entered in the system) only enters "M" at this time, then press the "F3" button to turn it immediately to: c: /> m myfile.asm This, if it is not required. LST and other files, then add one ";" C: /> m myfile.asm; "L" and "D" equally, the same method can be followed, it seems to be a small technique, but it actually saves time and energy.
Five, reference materials
In addition to specialized materials, the program should prepare a variety of reference materials or manuals for output, into, various surrounding equipment, etc. so that they can be found. Most importantly, software reference manuals MS-DOS Software Reference, which has various interrupt commands. Only, there should be some interrupt functions as the IBM BIOS. I suggest that readers don't use these interrupts. During their call, the speed will slow down. Secondly, the BIOS interrupt specification of IBM Programmer's Manual is the tool for processing all peripheral devices. Because it involves the peripheral equipment, it is necessary to be modified when designing Chinese systems, output, display, and printing, etc., this manual must be thoroughly understood. In addition, there is a keyboard input code table, which is also a must-have information, and this book is introduced for a brief code table. If it is written in the application, the above information is sufficient to cope, but if the system is involved, it is still necessary to understand the memory space arrangement of the system, which is the memory area structure of the IBM microcomputer. Although the various brand design concepts are different, they are similar to the same. Systems segment bit machine can address Use ┌──────────────┐ 0000 0000H │ interrupt call table │ ├──────────────┤ 0000 0500H │ DOS operating system and the area surrounding │ ├──────────────┤ 0000 4C00H │ control programs │ ├──────────────┤ 0000 5400H │COMMAND use │ ├──────────────┤ 0000 0E0A0H │ user operating space │ ├──────────────┤ 000A 0000H │ screen buffer (VGA) │ ├──────────────┤ 000B 0000H │ screen buffer (CGA, EGA) │ ├──────────────┤ 000C 0000H │EMS memory Body expansion zone │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─te When the incorporation is transmitted, the original 000ah should be 0a00h, and Yu Tong. The starting point of the user's operating space is different from each design. The second section of the application tool is made, the connection target file (Obj files)
After completion of the program, the linkage between each other is, the more difficult, sometimes the structure changes, sometimes the change of the file. Regardless of factors, it is necessary to maintain, and the relationship between work efficiency is significant.
Therefore, you need to establish a DO.BAT execution file, which is: 1 LINK / M @xxxx This xxxx is a record file, which records all target file names that need to be coupled, if there is any power, change this file directly I.e. Execute DO during coupling. For example: To make a DRAW.EXE file, DR1.Obj .. drn.obj and DR-seg.obj are already filed, then the XXXX file should be: 1: DR-SEG 2: DR1 DR2 .. DRN 3 : DRAW, DRAW, after performing DO, if there is no error, the resulting Draw.exe and Draw.SYM are available for testing.
It can also be added after the third step: 4: symdeb (or only s) Draw.exe Draw.SYM is like this, in the early stages of development, you can test it immediately. If you don't need to connect again, set the fourth other as a .bat file, execute it at any time.
In addition, it is important to note that in order to let the executable program start with the specified starting point, the title name of the point should be added together after the original file .ASM end format, add a title name. This marker will be the only entry with the first title that is the first title that is the first title. If there are a lot of programs, the program participating in the work is also more, and often use your own entrance when it is subsequently tested, and it may happen once it is counted. The solution is a program responsible for the coupling, preparation of the foregoing XXXX record files in advance, and put the program with the entry tag can be in front. Of course, delete the title after other programs, but it is not as high as the previous method.
Second, the target file detection and tool
When using Debug, because the name is short, the usage is simple. If you use the "Title Infraction" symdeb.exe, it is not much when you first generate .map file, test, input text. It is inevitable that people who are constantly useful. Simplified method, first production execution: S.BAT and SM.BAT
S.BAT is designed for designated program detection, the content is: 1symDeb% 1.SYM% 1.Exe This means that when there is already original file, if the program is just connected, and in the coupling No. Map statement, you should make sm.bat as follows: 1mapsym% 1. Map Use the "Title Dealog" tool with many advantages, its function is much stronger than debug. But the user must pay attention to the title of the test, should be announced in the program, otherwise it is not possible to jump directly to the office. There are still some special effects, and the tools should be prepared, even in a way of using the "monitor", and use another computer to control. There are some communication software, such as Xtalk plus symdeb.exe, can be displayed online by serial port, which is as follows:
1. Enter communication instructions on the host to be tested: C: /> Mode COM1: 9600, N, 8, 1 C: /> SYMDEB MyFile.exe
2, then enter: c: /> Xtalk enters the instruction input status, then enter: c: /> SP indicate the transfer speed, generally 9600, but depending on the host set. C: /> 9600 Finally, input operation instructions: C: /> Go LO indicates that the area network is used, ie the serial port. At this time, wait for the signal to successfully, see "-" on the screen, you can start the detection. 3. In the host, it is necessary to enter: c: /> = COM1 (or COM2, the communication port of both parties)
4. As for the method of detection, the same as the use of a computer, just the execution result appears on the host, and the subsequent control detection step. Section 3 Classification Definition
First, Segment Name Definition
For a program, it is best to have a program that defines segments. Taking DRAW as an example, it is assumed to be two segments, one as a control program, one is drawing program segment. The data is divided into three sections, one is the application information, one is reference information, and the production information. There is also a data index section, and there are six segments. Recommended, on the basis of general, simplify the paragraph, classified the paragraphs as follows: the code segment named Data Segment Named the DG Index Segment (IG memory) (Memory Segment) ) Named the MG special section (STACK segment) named SG
When each paragraph exceeds a group, add a number to distinguish it. As in DR-Seg.asm, it can be set to: 1: Title Segment Definition of Program ˉdraw 2: CG1 Segment Public 3: CG1 Ends 4: CG2 Segment PUBLIC 5: CG2 ENDS 6: DG1 Segment Public 7: DG1 ENDS 8: DG2 Segment Public 9: DG2 ENDS 10: DG3 SEGMENT PUBLIC 11: DG3 ENDS 12: IG Segment Public 13: IG Ends 14: End After Segment Public PUBLIC, there are several representations: segment public xxxx xxxx = code is expressed as the program segment, At the time of join, the segment of the partner is connected to the segment. Between the two programs, the first place in "Festival" is filled in 000 hours (each 16th "section"). XXXX = DATA indicates the data segment, and it is the same as the connection. If the program must strictly control the position and length of the program for some reason, it is not advisable to use the above two ways. The simplest statement, that is, after segment public, keep blank. XXXX = BYTE indicates that the program is tightly engaged, no vacancy. This method is conducive to the level of stylism. After the XXXX = Word represents the program, it is closely engaged between each manner, but the latter program will inevitably start from the double number. For example, quotation marks before and after XXXX, such as: segment public 'xxxx' this declaration, to notify the order and definition of each segment of the assembly process. Therefore, when writing the program, as long as the segment name and definition of use is consistent with this file, no matter the arrangement of each segment in any position, it is not an error. The 'xxxx' is related to the order of this parameter. When connecting, first sort the strings in the quotation, each program is arranged in this order. That is, any quotation marks, the order in which the program is used, that is, the order in the quotation marks, the order is sequentially. The error of single-ruler file is not difficult to detect, but if there is an error between sections, the programs that have insufficient experience will have no way to start, they have to be unpacking! Generally speaking, when connected, the most headache error message is: 'fixup overflow at nnnn ..' No matter what it is incorrect, most of this error occurs, mostly because the segment and segments are heading, buffering The use of the speculator is confusing, and the coupling is not correct. The solution is to stop assembly with 'ctrl_c' when the first error message appears, and records the first message. In the original, find this position, (mostly a title position) before this title, will Discover the errors related to "Segment".
Second, the source file file name definition
In the joint design of large modules, the tacit cooperation between the programming staff is full of prior. Otherwise, the larger the program, the more difficulties, the more difficult, often time consuming, and even finally defeat. Therefore, at the beginning of the design, it must be properly planned, and a corresponding file, name, function, etc. are clearly defined. The program participating in the design must strictly abide by and can be worn. The definition of the original file name is three: 1, the representative programmer: When the program has been made, the name of each program should be distinguished. Another example is programmed in one way, then add a number number after its own code. In this way, you can find any problems, you can find it to track. 2, representation of the program: Whenever a problem occurs, you should be able to check the problem by the file, so each function should be given appropriate names.
3, the relationship representative of the connection: In addition to function, there is time to indicate the connection between the various clauses. If a certain manual must be arranged before or after another, it should be finalized in the final, in order to represent the order. If the participating program is not more than the hospital, then the one is limited, and the people choose one letter in advance as the first word of the archive name. The second character will depend on whether the program is written in more than one program, and it takes a number representative, if it is not necessary. The function is suitable for three to six fresses, which will be more convenient for unified length, and the remaining one-word is for several order. Example: The program number is 'c', the number of this model is 3, the function is 'DRAWS', and there is no joint relationship, the name should be: cdraws3.asm
Third, the title definition
The maximum troubles are in organizing or tested, and it is to find the source or function of a title. If you can use Cref.exe in the same file, you can print a complimentary table; if you don't know which file is from it, in many programs, you only hope that Yang Xing is sigh. As for the function, if the name is too long, not only input, the modification is inconvenient, but will make the program make a mess, it is eye-catching. If it is too simple, it is difficult to understand anyone. Therefore, the importance of the title is not written by the writing. Especially in the number of participants, the title is not only unified, but also can represent all necessary messages. The message represented by the title is: a xxxxxxx │ └┬┘└┬┘└ - branch code │ │ └ - ─ ─ ────────────────────────────────────────────── ─ Project
1, the program source: If many people participate in a plan while participating, a program only wrote a program, this definition is the code of the program. Otherwise it is necessary to add numbers to check it at any time. Even if there is only one person writing program, the program may continue to expand, in order to make the convenience, or for the segmentation of the module, it is often necessary to divide the program into other files. Therefore, one program is from which file, the entire title indicates so that it can be found quickly. The program is usually used in one letter, as the first letter A represents this segment from the original gear from the number A; or a program that is a code specified by A.
2. Function Name: In addition to the functionality that will be used in advance, most of the remaining in the development process, it is desired to be required. Don't take a lightweight, one program, which is often defined, which is clearly defined, which can be clearly defined with its functional definition. The function name is preferably three letters. When it is too long, it is, especially the Chinese, not necessarily an English, and it is wrong with it, it is better to hide. Such as: DSP indicates that the screen display function PRN indicates that the print function KIN indicates the keyboard input function 3, the extension definition: If the function is too large, the definition method is difficult to distinguish, then the definition can be additionally defined. Such as: DSPDOT indicates that the PRNCHI indicates that the print Chinese Kinasc indicates the input ASCII character.
4, branch code: There is often branch in the program, the ideal of the branch code is small and sequential. But because writing is often difficult to predict, it should be left first in order to expand. Such as: dspdot10 prNchi06 Kinasc24
Fourth, buffer definition
B xxxxxxx ││ └┬┘└┬┘ ││ │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ─ ─ ─ ─ ─ buffer reserved word
The first letter regulates 'b' to reserve the word for the buffer. The second letter defines its type: Q = Qword, such as: BQXXXX buffer length is 8 characters. D = DWORD, such as: BDXXXX length is 4 characters. W = Word, such as: BWXXXX length is 2 characters. B = byte, such as: BBXXXX length is 1 character. S = string, such as: BSXXXX is not limited, but limited byte. O = Original, such as the original information of the Boxxxx table. F = flag such as: bfxxx is used as the flag. The function or extension definition is used in the second letter, and is the same as that of the three, 2, and 3. In addition, all buffers should be unified in buffer special programs, and if they are temporary, or have not formally connected, they should be in the first priority to facilitate access, modification.
Section 4 Uniform format
First, the advantages of the unified format
Regardless of the programming language, all work together, you must discuss each other, or in the same department, share the defeat responsibility, there should be a unified writing method. This not only facilitates communication, improves the quality of the program, but can avoid the sequelae caused by a deserialist or extension. Good program, such as a wonderful literary work, there are skills, intentional. Its functions are not only manifested in the efficiency of execution, but also the media that can be learned and appreciated, these must be reached through a unified format. In particular, the combined program is written as an artistic creation, and it must be often observed, and if there is no format, such a program and the "Tianshu" can be said to be much different. Whether the comment is better, the general programmad is afraid to see his own program, let alone refer to others? But if there is a unified format, after developing habits, not only easy to understand, but also find, easy to modify, write Easily save trouble. Second, specifications
1. Uniform use of uppercase letters to facilitate reading. 2, the space should be used in Tab, the head is equal to, and it is natural. 3. Immediately after the title will change the input so that you can read it. 4, each line must not exceed 70 letters, so as not to be unequal, the picture is disordered. 5. After the note is in the instruction, in the starting point of the fifth TAB, the space is in line, but the position is united. 6. All buffers are unfamiliar before the program, and it is not inclusively in the middle. 7, in addition to the FAR CALL that needs to be exceeded, do not use the 'proc near' form, because this writing method is meaningless. 8. At the beginning of the form, you should have a note instructions.
The following example shows unified format: 1: Page 60, 132 2: Title [program name], [program number], [Number], [function description] 3: 4: DG Segment public 5: EXTRN BWSCA1: Word, .. 6: DG ENDS 7: 8: .. 9: .. 10: .. 11: 12: CG Segment Public 13: EXTRN MMMM: NEAR, .. 14:. 15: Public XXXXX, YYYY, .. 16: Assume Cs: CG, DS: DG, ES: DG 17: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; 18:; Rem ............ 19:; ......................; 20: ;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;; 21: START: 22: CLD 23: MOV AX, DG 24: MOV DS, AX 25: .. 26: .. 27 : .. 28: 29: CG Ends 30: End Start
The first Page is a "reserved instruction" for the proprietary printed, indicating the number of rows and columns in each page. The rest thereafter 60, 132 is 60 lines, 132 characters. The second title is "Reserved Directive" for the inspection. In the aforementioned REM annotation bar, the function, application conditions of this section should be explained so that other programs are used together.
Third, the note
The purpose of the annotation is that he or others can easily modify and maintain it later. Therefore, the description will be described in detail. Unfortunately, no matter how exciting a quote, there is always a shortcomings. Therefore, you need to grasp the focus, generally, the program needs to be explained, no external: 1. Function: What kind of prerequisites are needed. 2, parameter: What data is set to supply this paragraph. 3, buffer: What buffer is used, how is its working characteristics. 4. Result: The result produced after execution. 5, Sonicular call: In this paragraph, the subscriber name of the call. 6. Important statements: If the scratch is destroyed, or other payments. Such as: [Function]: Read the keyboard buffer input code, return to the ASCII scan code or Chinese internal code 计 : AH = 00h [return]: 11Al <80H, AH = Scan code, Al = ASCII 12AL ≥80H, Al = four-character Chinese internal internal code [Destroy Speed ": AX [Remark]: Take the Chinese Code in this function, must be used 4 times, to get a Chinese 4-character internal code . Of course, if the time is sufficient, it is best to have all the documents, and the fine record of the production and modification. The problem is that at the beginning of any program development, it must be prolition. Plus constant modifications, supplement, and compute with changes in changes. The programmaster has to pay attention to the whole god, solve the problem, and consider how to pay, one heart, I must not talk about efficiency. So how do you do it? I suggest that the programmakers will be free to play, and there is nothing to do in the early days. The standby is completed, and there is no mistake. At this time, it should stop, from the head to the end, will completely organize the program. This is not only easy, but also the program has the opportunity to re-"appreciation" his own cardioculum, the change, the merger, the deletion of the deletion. Finally, the programmaster will reflect, research, and technology will have greatly improved, and the program is more streamlined, the notes are correct, and the work also achieves the highest efficiency.