-------------------------------------------------- ------------------------------ ※ For beginners, Masm's function is too strong, and many of its orders are too complicated. It is often hindered by our learning combined language. ※ Some high instructions have only been useful for quite experienced combined language program, for us, too much. ※ In fact, using MASM is like opening 747, only debug has the taste of propeller aircraft; because all control above the debug is directly related to the combination language. ※ If you feel that the combination language is quite interesting, you must use MASM. ※ In order to make the learning combination language have a good start, you must first eliminate those gorgeous complex orders to focus on the most important commands. ※ With your growth of MASM skills, you will feel that it will feel about your left and right hands in a combined language program. ※ Digital system is the most common "thinking mode" of the computer, and it is also the best tool for us and computer communication, you must know it. ※ At the same time, you will also know the structure of the middle / English internal code. ※ Hardware is the body of a personal computer, you must not ignore the relationship between hardware five parts. ※ The correct concept of memory and central processing is the entry course for combined language compulsory, you must be familiar with it. ※ The integrity of the operation system modelation is the basis of the combination language, you must completely understand it. ※ In ancient times, humans know how to use "symbol" to represent the number of objects. ※ At first, these symbols were only oral. ※ For example: a long-winged image, two stones, three people .... ※ Later, gradually evolved, the progressive digital system, such as: knot rope, painting line .... ※ With the evolution of human civilization, the number of people to calculate is getting more and more, and these methods are not very convenient. ※ The Romans attempt to represent a value of 1 in a separate symbol, for example: V represents 5, X represents 10, etc. ※ Although it is still impractical, it has opened a new direction for the modern digital system. ※ With the accumulation of experience, the Arabs summarizes some basic principles: 1. Number of values below a separate symbol. 2. When the value is exceeded, then restart again. 3. Use a special symbol to represent the "empty" line. ※ So, the Arab's hand index, the branch of the branch, creates the Arabic Number 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and 9. ※ In the combined language, we often add "D" after the value, indicating that it is a decimal number. ※ Because humans have ten fingers, we have become accustomed to the ten-in digital system by the convenience of the wrench. ※ God has created humans in their shape, the same, human beings pay their own body life. ※ The computer itself has the soul of the entity body and the thinking. ※ The computer's body is our common "hard", including five major units: arithmetic logic units, input units, control units, output units, memory units. ※ The soul of the computer is MS-DOS to control the operation of these five parts. ※ "Combined Language" is used to write the basic language of MS-DOS. ※ "Central Processing Unit, CPU" is mainly a microprocessor, which is a single wafer that can perform computer all arithmetic / logical operations and basic I / O control functions. ※ The relationship between the combined language and the specific microprocessor wafer is unparalleled, that is, the different microprocessor has the same language instruction syntax.
※ Personal computer has been launched by 1981, its main microprocessor development process is: 8088 → 80286 → 80386 → 80486. ※ The next microprocessor has a more powerful, and the directive is more complex, but it will include the function of the previous microprocessor. ※ In order to ensure that your combined language program can be applied to various models, it is still useful to use 8088's combined language, with the best compatibility. ※ "Getting Started" is also based on the 8088 combined language. ※ Like human brain cells, the computer uses ICs (including countless crystals) as "master memory". ※ Memory is a key component in computer operations, but also places where the computer stores information. ※ The organization of the main memory has many storage locations that can be stored, each with a "address". ※ The storage position used by the personal computer is composed of "8 bit", called "bit yuan group", which is a size that can put it in the information unit of a character. ※ "Memory" is a place where the computer can be used to store "bit yuan group" in the concept of a combination language designer. ※ Each memory location has a location where the location is used. ※ The address is a number, starting from scratch, and the highest address is increased. * Because the address is a number, the computer can calculate and process the memory position in its arithmetic capabilities, and the design of various computers has its address size. ※ 8088 series of personal computer is an open hard body architecture to internet access to other peripheral devices with "expansion slots". ※ There are 62 channels (I / O Channel) on each expansion slot, which assigned 20 memory. ※ That is, in 8088, there are 20 positions of Yuan Chang, so the microprocessor has a set of 220, which is equivalent to 1M1024K, 1K = 1024) Byte, which is also an effective control range of MS-DOS. ※ Most 8088 arithmetic arithmeters are limited to the 16-bit font, which range from 2 to 216, namely 0 to 64K. ※ Therefore, the concept of "segmentation address" must be used to control the entire address. ※ The complete 20-bit order can be divided into two parts, all of which consist of 16 positions: 1. Segment part (segment): The original 16 bits are added to add four binary 0 (a 16-in-one 0 ), Becoming 20 bits, can be set to any 64K section in 1 m. 2, relative part (OFFEC): directly using a 16-bit element to the segment part, pointing to any of the segments. ※ In fact, part of the segment is often a "basic address" that is capable of addressing the 64K work area. ※ In the combined language, you will often see the segmentation address: "2222: 3333" ※ Spections: It is an entity component inside the computer, a bit like a memory of the memory; however, due to it It is part of the microprocessor wafer, rather than a part of the memory wafer, so the data transfer between the speculation is very fast. * 8088 The instruction can also do many things that cannot be done on the memory location, for example: 1. You can perform arithmetic and logical operations within the scratch. 2. The location stored in the scaler can be used to point to a location of the memory. 3. The Terminal can be used to read and write the data to the peripheral device of the computer. * 8088 has 8 8-bit "general telecommunications", namely AH and Al, BH and BL, CH and Cl, DH and DL.
※ These 8-bit temporary registers can be paired to form a 16-bit tempolic register: AHal = AX "Accumulate Transmission" is often used for operation. BHBL = BX "Base Terminal" is often used in the location index. CHCL = CX "Count Reservsors" is often used. DHDL = dx "Information Transmission" is often used in data delivery. ※ In order to use all the addresses, 8088 also set four "section telecommunications", specifically to save the address part of the address: CS is used to set the code code segment (Code Segment) The address is located. DS is used to set the location of the data segment (Data Segment). SS is used to set the address of the stack segment. ES is used to set the location of the extra section (Extra Segment). * When a program is to be executed, DOS is to determine the program, data, and stacks to use those positions, and set the section temporary depositor CS, DS, SS to point to these starting positions. ※ Usually the programming language process is fixed to the "Data Section Transmission", and modifies the "Program Segment Transmission-CS" as needed. ※ So, the DOS and "Programming Machine" can be written to be written in the case of less than 64K, in the case where the available space is less than 64K. ※ In general, the Basic Zeter is a program processor, and the Basic program you think is actually part of its information. ※ So, your program and its data are combined, limiting within 64K covered by DS. ※ This is the reason why the Basic program and the COM file must not be greater than 64K. ※ 8088 As a workplace in memory, it uses a temporary depository as a draft paper to accelerate. ※ In addition to the scratcher mentioned earlier, there are some special features: IP instruction indicators (INTRUCTION POINTER) Terminal Trieutical Pointer Trieutical Pointer Trier and CS Used, can be tracked. SP Stacking Indicators (Stack Pointer) Trieutical is used with SS to point to the current stacking position. The Base Pointer Speed Speaking (Base Pointer) Specifier can be used as a relative base location of the SS section. The Source Index Source Index (Source Index) Speaker can be used to provide a source indicator relative to the DS section. Destination Index Specification (Destination Index) Specification can be used to provide an indicator relative to the ES segment. ※ Computer must be able to react with events that occur outside of its microprocessor. ※ We can use two ways to achieve this: 1. Pooling: The computer is constantly looking for an incident that needs attention, but it is not used to take a lot of time in the inspection work, so it is not used.
2. Interrupt method: The computer is quietly doing itself until the event causes it to pay attention. ※ "Interrupt" makes the microprocessor will not waste time in finding work, but when there is an incident to complete, work will come to find a microprocessor; this is the main factor in the efficiency of the computer. ※ The main concept of interrupt is: Anything that needs to be handled, it is used to find a processor in the form of interruption; according to its function, it can be divided into three categories: 1. "Hardware interrupt": is from some kind of external Equipment (eg, a disk, keyboard, printing machine, etc.) requires the attention. 2. "Logical Interrupt": is produced by the processor itself in certain abnormalities (exemplified: divided by zero). 3. "Software Interrupt": The service used for general public uses by ROM-BIOS and Delogos. ※ "Software Interrupt" is very important to the homework of the personal computer, which is the most commonly used in combination language and other high-order language communication. ※ Stack is to place its work in a manner that does not interfere with each other. Information, with interrupt matching, make the computer efficiency and capacity increase. ※ The stacking work mode is in the buffet restaurant, when the plate rack used, puts down or takes the plate, all starts with the top, this is the principle of "backward first". ※ When the computer is busy with the work and receive an interruption, you need a place to save the record that is doing, and then perform an interrupt service. ※ When the interrupt service is completed, the computer must continue to be doing things. ※ The working mode of stack in the computer is: 1. Some memory (low) is supplied to the stacked storage. 2. Point the memory area where the stack is located with a special stacking scrapper SS. 3. The top of the stack is indicated by the SP scaling. ※ The 8088, which is the central nervous of the computer, actually only knows the three things other than it itself: 1. It will hit the head to get the external interrupt. 2. Memory with it talks. 3. Transfer data to the only way to enter and enter the memory (port) of anywhere. ※ That is, 8088 is communicated with the outside world via interrupt, memory. ※ (port) is an 8088 microprocessor to replace and unify its mechanism with an external communication method. ※ Microprocessor is for anything that needs to be tongued, for example: keyboard, disk machine, speaker, etc., will be used for use. ※ The computer is working hard by hardware, but it needs to guide the body of the body by thinking to guide the "software" is the idea of the computer. ※ Software is used to make the computer smoothly, among them, "homework systems" is the most important pioneer of software, and is the most important and most complex program. ※ Most of the work system "DOS" is hidden to hide some very redundant details so that we can easily use computers. ※ The key one of DOS success is "Modularization" ※ When the designer makes DOS to make the work clearly into each module, it is simplified and efficient. ※ Of course, these modules must be organized into a class of careful definitions, where each layer has its specific work, but it is not necessary to consider the work details of other class. ※ The operating system is cut into six major modules according to the actual needs: 1. "ROM-BIOS": Provides basic and preliminary services required to computers. 2. "Boot Record": used to load DOS. 3. "IO.SYS": as a variable expansion of the ROM-BIOS. 4. "MSDOS.SYS": Provides the core DOS service. 5. "Command.com": handles the DOS command you typed. 6. "External Program": Used to provide a special service program.
※ Among them, MSDOS.sys is the "logical part" of the operating system, while ROM-BIOS and IO.SYS constitute "entity part". ※ Our commonly used disk operation system "MS-DOS" is usually referred to as a module other than ROM-BIOS. ※ We can imagine the entire homework system as "DOS Co., Ltd.", and the part of the system is equivalent to "class" in the company. ※ "Basic Output System in Memory, ROM-BIOS" provides some of the most basic and preliminary services, which are equivalent to actual work in the factory. ※ The ROM-BIOS is built in the PC in the manufacturer, which is the hardware of the computer to change the hardware to modify the system. ※ The services provided by the ROM-BIOS (prior) are mainly: 1. Self-test program when turning on the power. 2. Start and load the DOS. 3. Support all the standards of all standard peripherals. ※ "Enabled, boot recrod" is equivalent to guard, and is placed in a RECORD of the system magnetic, used to load IO.SYS to start DOS. ※ Since the size of the starter is a standard magnetic area (Sector, 512 Byte), some fixed information can only be stored. ※ Therefore, in the system magnetic sheet, two files must be included in IO.SYS and MSDOS.SYS, and they are placed in a standard and pre-set position. ※ So, you cannot easily turn ordinary magnets into system magnets because the location of this special system file may be occupied by other files. ※ Because the enclosure cannot look for the position of these two files, only they exist; so they are set to hidden files and system files to avoid deleting or remarining. ※ The startup must only be changed when the system file changes size or position, so you will find different startings on different versions of DOS. ※ IO.SYS is like a foreman, in addition to monitoring the ROM-BIOS action, it is necessary to replace the ROM-BIOS to expand its function; when other programs are used to use r-bios, they must be transmitted via IO.SYS. . ※ IO.SYS has a function of ROM-BIOS that cannot be done: 1. Setup for specific needs for special DOS. 2. If necessary, you can patch any errors in any ROM-BIOS. 3. Easily handle new peripheral devices. ※ DOS is in the way "Configuring, config.sys", so that the PC can add new devices to make the surroundings of the computer. ※ DOS puts the "device processing program" in the configuration file as an additional load of IO.SYS, producing a new peripheral new device in a module, and interfering to the DOS system file, this is also DOS concept A big breakthrough. ※ MSDOS.sys Problem is more comprehensive, just like the company's manager ※ MSDOS.sys contains the DOS service of the output, "DOS Interrupt Service": It is used to directly obtain the control DOS error. 2. "DOS Function Call Service": Output service for indirectly provided. ※ Most "DOS Service Circular" is often used by a higher level DOS program. When the combined language is executed, it will contact it. ※ In fact, the real output is in the BOM-BIOS, but the program must use them through MSDOS.sys. ※ All DOS services and ROM-BIOS services are intentionally set into a format used only by the combined language to increase efficiency, which is also a combination language truly charming place. ※ Command.com is responsible for controlling the entire action of the operating system, which can be said to be a systematic decision part.
※ Command.com is actually divided into three parts: "Resident part, Resident Part": includes basic control functions and error handling common, start with IO.SYS and MSDOS.SYS when booting. 2. "Open Part": Only when the DOS is turned on, it is used to check and execute an autoexec.bat file. Once you are done, this part is discarded. 3. "Temcer Section, Transient Part": The program contains the command translator and executes the DOS internal command, which has a lot of space. If the external program needs to be large, DOS will release this space to Later delivery. ※ After the normal execution, Command.com's resident part will check whether the life translator is covered, if there is, then load it from the DOS magnetic sheet. ※ This is sometimes you use certain programs that DOS will ask you to add a magnetic sheet. ※ Since the DOS copyright announcement and internal commands are stored in the Command.com file, each company can be authorized to Microsoft, and changed from a unique DOS version, which is one of the reasons for the independence of Command.com. ※ When we perform a program in a combined language, this program temporarily manages the work of Command.com, and you can use all the features of MSDo, IO, ROM-BIOS, and command.com can only be able to end. Retrieve the control. ※ So, who tells command.com what should I do? It is you, more accurately, is the command you entered after prompting symbol A>. ※ In addition to the part discussed above, the following parts of the DOS are in the program of "external command", and placed in the program of the magnetic sheet. ※ External command except for a small part (such as: format, etc.), mostly non-DOS must, it can be considered a public program of assist DOS, not the operating system itself. ※ External commands such as debug and edlin are most commonly used when writing a combined language. ※ There are two main methods for writing a combination language: 1. Use "Compile Program: Masm". 2. Use the "Disregard :debug". ※ Debug is actually a "group translation program, assembly", which is the main purpose is "except", that is, the error in the combination language program. ※ However, you can also use Debug to write short combined language programs, especially for beginners, DEBUG is the best entry tool for learning combined languages: "Easy" ※ Use Debug to type and execute, as long as Call debug can be simpler. ※ When using the group translator, you must use the documentary programming, the group transcripts, link, and EXE2BIN equation, each of which must be used to work with a quite complex command. "Less Less Less Less" ※ In the true portfolio language of the original program, the procedures that appear, must set some additional programs in the beginning of the program to the group depot. ※ Using Debug can avoid a lot of difficult-in-order columns that have been encountered at the beginning. "Close Close Machine" ※ Using DEBUG is more able to contact the actual operation situation of the computer than using the group translation. ※ Debug's characteristics allow us to touch the most basic level of computer operation. ※ When writing programs in a combination language, you must understand this level sooner or later, and use Debug with learning to deactivate, so learn Debug first seems to be a good start. "Applicable to Short Rules" ※ The group translation has a lot of strong features, which is indispensable to group translation. ※ However, for beginners, Debug is already enough.
※ Using Debug, you can more focused on the exploration of the combination language, without having to be scared by those complicated characteristics. "The window of the soul of 8088" ※ The eyes are the window of the soul, and Debug can explain the window of the 8088 soul. ※ DEBUG can be used to check and modify the memory location, load storage and execution, and check and modify the teleconcorder. ※ In other words, DEBUG is designed to allow us to contact various entity characteristics of the PC. ※ When you insert a magnetic disk containing the debug into the disk machine A, you can start the debug, the DOS prompt A> is waiting for your next indication. ※ In this system, if prompted "Please enter ...", then press ENTER, if you mention "Please click ...", then press this button directly. 1. Please enter Debug (remember to add an Enter) 2. The short line that appears on the screen is the debug's prompt symbol, indicating that Debug is ready to accept your command. ※ DEBUG's command is represented by "single letters", which is usually followed by one or more values. ※ The role of the D command is to put a portion of the memory of the memory on the screen. ※ Syntax: "D ※ Syntax: "F ※ We can use the combined language instruction to write the program, the a command is a machine code used to translate the combined language instruction "translation, assemble" into a hex value. ※ The program written in Debug must be valid by the address 100h. 1. Enter the A100 2. Please enter MOV DL, 1 3. Please enter MOV AH, 2 4. Please enter int 21 5. Please enter int 20 6. Please press ENTER key 7 Now you have placed a combined language program into your memory. Please enter G 8. The result appears on the screen will be the same as the program written with the E command. Program Terminated Normally 9. Please enter D100 10. Address 100 to 107 is the content of the program, like the machine code written in E. 1FED: 0100 B2 01 B4 02 CD 21 CD 20-00 00 00 00 00 00 00 00 ..... ........ 1FED:!. 0110 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 ................ 1FED: 0120 00 00 00 00 00 00 00 00 00 00 00 00 00 ......... ....... 1FED: 0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1FED: 0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1FED: 0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00. ............... 1FED: 0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00- . machine code 0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ※ we can use the U command to hex bits: 1FED Unassemble translation into a combined language instruction, grammar: "U ※ Input: AH = 2dl = Value of the Value ※ Execute: InT21 Result: The character is displayed on the screen ※ INT 21: DOS interrupt service, used by the function call, the program can be transparent This interrupt is interrupted to call all DOS function services. ※ INT 20: DOS interrupt service, used to terminate the program, after executing, handle the control to Debug, and appear Program Terminal Normal message. ※ The R command can be used to view the scratcher (register) in 8088, or to change the content of the temporary register. ※ Do you remember the meaning of each register? ※ Please pay attention to the IP tensioner, which saves the current execution of the current execution. 1. Please enter the R AX = 0000 bx = 0000 cx = 0000 dx = 0000 sp = ffee bp = 0000 Si = 0000 di = 0000 DS = 1FED ES = 1FED SS = 1FED CS = 1FED IP = 0100 NV Up EI PL NZ NA PO NC 1FED: 0100 B201 MOV DL, 01 - 1. When executed by 100, the DEBUG automatically updates the content update of IP to 100 at the end of the INT 20 instruction. * When you want to make this program into a separate external program so that you can execute in the DOS prompt symbol, you must name the program with n commands. ※ The program file must be COM, otherwise it will not be loaded next time. ※ Syntax: N-program name>. COM 1. Please enter nsmile.com ※ Next, you must tell Debug how long this program: the program starts from 100 to 106, so actually occupying 7 positions. ※ We store this value of this value by using the BX scaler to store the low torrential part of this value with the CX specification. 2. Please enter the RBX (see the contents of the BX Speaker) 3. Because the BX is set to 0, press Enter 4. Please enter the RCX (see the contents of the CX Speaker) 5. Please enter 7 ( The number of bits of the program) ※ Finally, write the (WRITE) magnetic sheet with the W command. 6. Please enter W ※ When we write a combination language program, we usually do not directly put the hexadecimal bits (machine code) into the memory, but to enter a string "help symbol" ( MNEMonic Symbols, these symbols are easier than hexadecimal. ※ The help symbol represents a certain combination language instruction with the name of 2 or 3 fonts to tell the microprocessing machine. ※ That is to say, the combined language composed of the help symbol is designed for humans, and the machine language is designed for the characteristics of the PC. ※ In fact, the 8088 microprocessor actually can read and understand the hexadecimal value, but the two-in-one or bit is form; the hexadecimal only makes human beings more easy to understand the binary number. Yes. ※ Remember the ASCII code? Now let's analyze a program that can display all ASCII code on the screen. ※ Please load and execute the program ASCII.com in the disk. 1. Please enter debug ascii.com 2. Please enter U100, 10E 1FED: 0100 B90001 MOV CX, 0100 1FED: 0103 B200 MOV DL, 00 1FED: 0105 B402 MOV AH, 02 1FED: 0107 CD21 INT 21 1FED: 0109 FEC2 INC DL 1FED: 010b E2F8 LOOP 0105 1FED: 010D CD20 INT 20 - ※ Inc: Incremental instructions, each time the numerical value in the data transmission device DL is 1. ※ LOOP: Back ring command, place the number of times in the count Transmission CX, each execution of the LOOP instruction, the content value of the CX is reduced, and jumps back to the beginning site of the loop (105) until CX is 0. 1. Please enter G ※ When we want to display a string on the screen (for example: when the computer will ask you), you can use DOS's 9H number function service. ※ Please enter the next list, store it in a "Hallo.com), and execute it: 1. Please enter the A100 2. Please enter MOV DX, 109 3. Please enter MOV AH, 9 4. Please enter int 21 5 Please enter int 20 6. Please enter DB 'How are you, su $' ※ Column screen string function: DOS 09H number function service. ※ Enter :ah = 9DS: DX = Sprunch start address ※ Execute :int in21 Result: String display on the screen of DX: string offset site, that is, actual Start address. DS: Strings segment, Debug will automatically check its value and do not have to manage it. ※ In the combined language, there are two different instructions: 1. Regular directives: such as MOV, etc., is an instruction that belongs to the microprocessor, which is used to tell 8088 microprocessor what should be done when executed, so it will The OP-Code is stored in the memory. 2. Virtual instructions: such as DB, etc., is a directive to which the Debug is used to tell the group translator what should be done in the group translation. ※ DB (Define Byte) instructions are used to tell Debug to place the bit group (ASCII code) corresponding to all the characters in the back single quotes into the memory. ※ The string of printing using a 9H function must end with the symbol. ※ When you want to see the DB virtual instructions When you put those packet groups into your memory, use the u command is not too large, and the D command is changed to get a better effect. 5. Please enter U100, 118 6. Please enter D100, 17F 1FED: 0100 BA0901 MOV DX, 0109 1FED: 0103 B409 MOV AH, 09 1FED: 0105 CD21 INT 21 1FED: 0107 CD20 INT 20 1FED: 0109 48 DEC AX 1FED: 010A 6F DB 6F 1FED: 010B 7720 JA 012D 1FED: 010D 61 DB 61 1FED: 010e 7265 JB 0175 1FED: 0110 20796F AND [BX DI 6F], BH 1FED: 0113 752C JNZ 0141 1FED: 0115 205355 AND [BP Di 55], DL 1FED: 0118 2400 and Al, 00 - 1FED: 0100 BA 09 01 B4 09 CD 21 CD-20 48 6F 77 20 61 72 65 ...!. How are 1FED: 0110 20 79 6F 75 2C 20 53 55-24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .... ............ 1FED: 0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1FED: 0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00ks. 00 00 00 00 ................ 1FED: 0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 .......... ...... 1FED: 0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1FED- ※ now, let's analyze A more artistic program: You can enter any strings by the keyboard, then displays once again . ※ Please load and execute the program mirror.com in the disk. 1. Please enter nmirror.com 3. Please enter G 2. Please enter this is my program $ ※ Provide buffer keyboard input: DOS 0AH number function service. ※ Enter :ah = ads: DX = buffer address ※ Execute :int 21 Result: Keyboard font exits ※ The buffer is actually a series of memory locations, whose size is DB is defined. ※ The presentation DB 20 indicates that DEBUG is used to reserve the unused memory location for buffer, and store the value 20H into the first bit set (116). ※ When you enter a string and press ENTER, the 0AH number of the DOS will save the virtual input character number (117). 1FED: 0100 MOV DX, 0116 1FED: 0103 MOV AH, 0A 1FED: 0105 INT 21 1FED: 0107 MOV DL, 0A 1FED: 0109 MOV AH, 02 1FED: 010B INT 21 1FED: 010D MOV DX, 0118 1FED: 0110 MOV AH , 09 1FED: 0114 INT 21 1FED: 0114 INT 20 1FED: 0116 DB 20 ※ Since the buffer keyboard input function AH will print an ingredient character (generated by the ENTER key), so that the cursor will automatically return To the front end of the input column. ※ In order to make the string of the screen map output without covering the original input string, a challlet filter (OAH) is printed using the function 2H, so that the cursor is moved to the front end of the next column. ※ Column screen string function 9h's DX specisculator wants to save the start position of the string. ※ Keep in mind: 9h function will only stop outputting the character when you encounter a $ symbol, so you must add a number of symbols in the string, otherwise the 9h function will continue to print unsearrable information in the memory. ※ "Group translation, Assembler" can convert symbol instructions into machine language. ※ "Machine Language" is a truly PC memory, and the binary value performed by the 8088 processor. ※ The program consisting of a binary value can be stored on the magnetic sheet in the form of COM. ※ When writing a longer combination language, if we want to pass 8088 reference manual one by one, combine each instruction into a destination code, you will not think that the learning group language is a meaningful thing. ※ However, during the process of machine language programming, the most could not be combined with human heaven, but it is the "combination" itself. ※ "Workers must have a good fault, you must first make a tool", Micrsoft Masm is the best PC's best group translation, automatically converts the combined language into a machine language. ※ It is better to say that it is better to say similar to the DEBUG-like group translator. ※ Debug's A command can transfer each symbolic command to a machine language, stored in the memory, and execute immediately. ※ The operation of the true group translator (MASM) is to use the instrument processing (such as :EDlin, pe II, etc.) to build a symbolic directive into a text file that is completely independent and ancillated .asm. ※ This article is also known as "raw code file", which is the input section of the MASM program. ※ MASM will translate the input ASM file and build a .Obj disk file, called "Destination Code Archive, Objet". ※ The OBJ file contains only the relevant parts of the relevant part to load and how to combine with other items, cannot be directly loaded into the memory. ※ "Link Program, Link" can help us convert the OBJ file into an EXE file that can load memory execution (Execute). ※ You can also use the "EXE2BIN, Execute to Binary" file to convert the EXE file to a COM (Command) profile. ※ DOS's Command.com is directly looking for a command in the appropriate magnetic sheet when performing an external command, and executes. ※ The command has three classes to distinguish between its accessory files; command.com is looking for a fixed order each time, and its priority is COM → EXE → BAT. ※ The COM file is composed of the two-in-borne value required by the program, which is the simplest way of storage, not only the least memory, but the speed is the fastest. ※ The EXE file except for the binary value, and also includes "pit, header" composed of various information related to the file, so the file is large. ※ The COM file can be directly returned to Debug directly, while the EXE file requires a more complex return. ※ When loading the COM file, it cannot be kept up with other files, so the COM file that has more than 64K memory space cannot be generated; and the EXE file is more likely to perform different functions, so it can exceed 64K. BYTES. ※ Because the start school is not large, and in order to fully understand all the processes, we use the COM file as the first combined language program. ※ The original code file of a smile.asm is established using the instrument process. ※ The blank line in the ASM file can help you divide the schema's architecture for reading. ※ MASM will assume all the values to ten into the bits, while Debug uses a hexadecimal; so in the original code, we must add H to represent the hexadecimal. ※ If it is a hexadecimal number starting with letters, it must also add 0 to the letter to indicate that it is a number. Original program code Debug program Prognam Segment Assume CS: Prognam Mov DL, 1 MOV DL, 1 MOV AH, 2 MOV AH, 2 INT 21H INT 21 INT 20H INT 20 ProgNAM Ends End ※ The original program code has been added to the quarter: ※ Prognam segment is pair, used to tell Masm and Link, this program will be placed in a "logram name)" "" "in the section name (progNam) However, its location must be fixed, and the two section names must be the same. ※ Assume CS: ProgNam must start at the beginning of the program, used to tell the group translator, the location of the section where this program is located in the CS speculation. ※ End is used to tell MASM, the program ends. ※ All the original program code to produce a COM file must contain these four columns, and must appear according to the same order and location. ※ When translates an ASM file in Masm.exe, you cannot be entered into the attached file name ASM. ※ The group session will ask you to enter an OBJ file, a form (LST) file and the control (CRF) file (CRF) file (CRF) file name, you only need to press ENTER, indicating that its preset name is used. ※ NUL indicates no file, so the result of the final group translation only generates smile.obj. 1. Please enter MASM SMILE 2. Press the ENTER button three times. . Microsoft (R) Macro Assembler Version 5.10 Copyright (C) Microsoft Corp 1981, 1988. All rights reserved Object filename [SMILE.OBJ]: Source listing [NUL.LST]: Cross-reference [NUL.CRF]: 50162 403867 BYTES SYMBOL SPACE 0 WARNING ERRORS 0 Severe Errors ※: Warning error, indicating that the group translator does not understand some things, but it is not serious to make the results of the program. ※: Severe error, the error that cannot be performed normally ※ The error must be corrected before using LINK. ※ The OBJ file is included in the two-in-one result after the group translation, which is not performed by the DOS loaded into the memory, and it must be linked. ※ When linking the OBJ file (Smile.obj) into an EXE file (smile.exe), the accessory file is not available. 1. Please enter link smile 2. Press the ENTER button three times. Microsoft (R) Overlay Linker Version 3.64 Copyright (C) Microsoft Corp 1981, 1988. All Rights Reserved. Run file [smile.exe]: List file [Nul.map]: libraries [.lib]: LINK: WARNING L4021: NO Stack segment ※ [.lib]:: The program library is some collection of programs. In special cases, it can be used with your programs. ※ Because the COM file does not use a stack segment, the error message "No Stack Segment" does not affect the normal implementation of the program, just adding our nervousness. ※ When using EXE2BIN to convert the exe file to the COM file (Smile.com), the former does not have to use the accessory file, and the latter must specify the subscriber name, otherwise, BIN file will be generated (smile.bin) . ※ In fact, BIN file is identical to the COM file, but because Command.com only knows COM, EXE and BAT files, BIN file cannot be executed correctly. 1. Please enter the exe2bin smile.com ※ Now there should be a smile.com file on the magnetic sheet. You can execute this program directly under the prompt symbol A>, you can enter the file name SMILE. 1. Please do this. ※ Do you feel that the method of generating a program is more troublesome than Debug! ※ It is true that the small rules are true; but for larger prices, you can find its advantages. ※ We use the ASCII program to do again in the form of translator, see if there is different differences. ※ First, you must first use the document processing program to establish an ASCII.asm file. prognam segment; start of segment assume cs: prognam; assume what's in CS mov cx, 100h; put counter in CX mov dl, 0; first ASCII character next: mov ah, 2; Display Output Function int 21h; call DOS to print inc DL; Next Ascii Chaacter Loop Next; Do Again, Until Counter = 0 INT 20H; RETURN TO DOS Prognam Ends; End of Segment End; End of Assembly ※ In the original program code of the combined language, each program list contains four items Element: START: MOV DL, 1; First Character Mark Operator Operator Operation Yuan Note ※ In the original file, the annotation can make the program more easy to understand, which is convenient for future reference. ※ Each column is based on ";". ※ The group session will be annotated as the narrative of ";" and not paying attention. ※ The information on the annotation column will not appear in the OBJ, EXE or COM file. ※ Under the Chinese system, annotations can also be used, but for program portability, it is recommended that you still practice English! * Because we don't know the location of each program, we must represent the relative address in the symbol name, called "Symbol Address". As NEXT: MOV AH, 2; DISPLAY OUTPUT FUNCTION NEXT: ※ We typically type the symbol site on the marking bar where appropriate column. ※ When you want to modify the program, you will find that the use of tags make the program have a large elasticity, as the group translation will automatically calculate the symbol address in the tagnap. ※ Label has up to 31 words, so we are in the program, try to make a mark as a simple and easy-to-understand text. ※ The tag bar is the first column of each column, and the instruction to be marked is also in the same column, and can also be in the previous column of the instruction. ※ Now you can translate this Ascii.asm file group to AsCII.com. 1. Please enter MASM ASCII 3. Please enter exe2bin ascii ascii.com 2. Please enter link ASCII 4. Please enter ASCII Microsoft (R) Macro Assembler Version 5.10 Copyright (c) Microsoft Corp 1981, 1988. All Rights Reserved. Object FileName [AsCII.Obj]: Source Listing [Nul.lst]: Cross-Reference [Nul.crf]: 48096 403883 BYTES SYMBOL SPACE 0 WARNING ERRORS 0 Severe Errors ※ For beginners, Masm's function is too strong. Many of its orders are too complicated, so that we will hinder our intelligence and effects of our learning combination language. ※ Some high instructions have only been useful for quite experienced combined language program, for us, too much. ※ In fact, using MASM is like opening 747, only debug has the taste of propeller aircraft; because all control above the debug is directly related to the combination language. ※ If you feel that the combination language is quite interesting, you must use MASM. ※ In order to make the learning combination language have a good start, you must first eliminate those gorgeous complex orders to focus on the most important commands. ※ With your growth of MASM skills, you will feel that it will feel about your left and right hands in a combined language program. ※ When you combine your own design, you will typically write a typing error, and the name of the help symbol is scattered, and the hexadecimal number is less H, logical error, etc. ※ The advice of the combination language is often given to the freshman is: It is best to expect some of the programs you will be somewhat errors. ※ If the first executive program is reasonable, you are best to take a skeptical heart because it may be wrong. ※ In principle, as long as the general logical architecture is correct, the process of excavating the middle question should have the same fun with the writing program itself. ※ When writing a large-scale, it is best to divide many modules, so that the destination itself is simple, easy to write and repair; it can also make the interface between the different parts of the program can be more clear. And save time. ※ We will write a "large-scale" that can be displayed from the keyboard to get a decisive value, and display it to the "Safe" on the screen. ※ To make this 8088 microprocessor to perform such functions, we must first break this problem into a series of steps, called "program planning". ※ First, in a flow chart, it is not a problem with the logic of the entire program. ※ You can use a "virtual language" that is bound to English and 8088 to interpret programs, such as the issue of expressing program planning in Basic's way. ※ Finally, the "virtual program" is changed to the 8088 combination language. ※ This modeling planning method is called "the top-down program plan". ※ In the truly write program, it is written from the smallest unit (module). After each module is completed, it will be merged into a generic program; this place looks at the way, the small way is called "From the lower program design". ※ Our first module is BiniHex, which is the main purpose to remove the binary number from the 8088 BX specification, and display on the screen with a hexadecimal manner. BiniHex Segment; Start of Segment Assume CS: BiniHex Mov Ch, 4; Number of Digits Rotate: MOV CL, 4; Set Count To 4 Bits ROL BX, Cl; Left Digit To Right Mov Al, Bl; Move To Al And Al, 0FH; MASK OFF LEFT DIGIT ADD AL, 30H; Convert HEX TO ASCII CMP AL, 3AH; IS IT> 9 JL Printit; Jump If Digit = 0 to 9 Add Al, 7H; Digit Is A TO F Printit: Mov DL, Al PUT ASCII CHAR IN DL MOV AH, 2; DISPLAY OUTPUT FINCT INT 21H; Call Dos Dec Ch; DONE 4 DIGITS? JNZ Rotate; Not Yet INT 20H; RETURN from BiniHex BiniHex Ends; End of Segment End ※ Use Rotating Instruction ROL Rotation The contents of the scratch BX in order to process 4 hexadecimal numbers sequentially: 1. Use the CL Terminal When the counter is used, the number of temporary movements will be recorded. 2. Move the first hexadacity value of BX to the far right. ※ With the AND instruction (two computational elements are 1, the result is 1) Cooperate with "Mask, Mask" to cover up not to part to get a simple result: 1. Save the BL value to Al In the middle, it is a case in a 0FH (00001111). 2. Use the AND characteristics to cover the left side of the left. ※ Since the ASCII value of the fifmers 0 to 9 is 30 h ~ 39h, the A to F ASCII value is 41h to 46h, where the phase difference is 7, so the result is: if the container is less than 3ah, the AL value is only 30 h. Otherwise, Al is worth 7 h. ※ The add instruction adds two computational elements, and the result is stored inside the arithmetic element on the left. ※ The flag is only a scratcher with only one bit, set into a separate hexadecune system, called "Flag Reservoir, Flag Register". ※ Some combined language instructions (mostly those related to comparison, arithmetic or logical operations) are executed, and the associated flag is set (1) or clear (0). ※ You often encounter the flag of zero value flag (ZR / NZ), the positive and negative flag (NG / PL), overwhelming flag (OV / NV), and carry flag (CY / NC). ※ The flag saves the result of an instruction execution, and other related instructions can be used, and the issued situation can be used to generate a relatively action in response to it. ※ The action of the CMP instruction is very similar to subtraction, and it is compared to the value of the two computational elements. ※ After execution, the content of the temporary or memory has not changed, but the relative flag is changed: if the content of Al is less than 3AH, the logagar flag will be set to NG (-), and inverse It is PL ( ). ※ The JL instruction can directly want to become "false, Jump if less" to the memory location specified by the arithmetic element bar. ※ CMP instructions and JG, JL and other conditional jump instructions are used together, and the program "branch, BRANCH" structure can be formed, which is a technique that writes a combined language program. ※ "JNZ, JUMP IF IF ZERO" instruction, which is functionally jumped to the memory address specified by the computational element when the zero value flag is not set. ※ The second module Decibino is used to receive the ten-way digits of the keyboard, and convert it into a binary number in the BX Terminal for BiniHex. ※ The process and program code of this program are not difficult. Do you have abdomen? Decibin Segment Assume CS: Decibin Mov BX, 0; Clear Bx for Number Newchar: Mov Ah, 1; Keyboard Input INT 21H; Call Dos Sub Al, 30H; ASCII To Binary JL EXIT; JUMP IF <0 CMP Al, 9D; IS IT> 9D? JG Exit; Yes, Not Dec Digit CBW; BYTE IN Al To Word in Ax Xchg AX, BX; Trade Digit & Number MoV CX, 10D; PUT 10 DEC IN CX MUL CX; Number Times 10 XCHG AX, BX Trade Number & Digit Add BX, AX; Add Digit To Number Jmp Newchar; Get NEXT DIGIT EXIT: INT 20; RETURN From Decibin Decibin Ends; End of Decibin Proc End ※ The subtration command SUB will subtract the arithmetic elements of the left to the right The calculation element, the result is existed in the arithmetic element on the left. ※ The JG directive cooperates with the CMP instruction. If the CMP instruction left the calculation element is greater than the right arithmetic element, the memory address specified by its operational calculation is jumped. ※ The CBW instruction converts the bit group (8-bit) in the Al scalar into a group (16-bit element) and put it in the AX Terminal. ※ The actual result is: "If the value in Al is positive, the AH is filled in 00h; then, the AH is filled in the FFH" ※ XCHG instructions will intermine the contents of the two computational elements. ※ When it is often used to temporarily retain the contents in a registered value. ※ The MUL instruction will multiply the contents of the computational element with the contents of the A-register, and save the results in the A-register. ※ Of course, we have to add a CRLF small-range, used to print the ingredient character (CR) and the redo-column (LF), so that the result displayed the hexadecimal number does not cover the original input 10 number. CRLF MOV DL, 0DH; Carriage Return Mov AH, 2; DISPLAY FUNT 21H; Call DOS MOV DL, 0AH; LINEFEED MOV AH, 2; DISPLAY FUNT 21H; Call Dos Int 20; Return from CRLF CRLF Ends end ※ Now we can combine BiniHex, Decibin, and CRLF components into a complete big course. ※ First, we must change these three modules to "Programs, Procedure", then write a short small speed to turn through each program. ※ The so-called program is made of a group of combined language instructions, usually used to perform specific, complete work, in the computer language, often referred to as "Submit". CRLF Proc Near MOV DL, 0DH MOV AH, 2 INT 21H MOV DL, 0AH MOV AH, 2 INT 21H RET CRLF ENDP ※ Similar segment and ends virtual instructions, PROC and ENDP are used to identify and define a program. ※ In fact, the true role of Proc is just telling the group translator: the programs of the call are proximal or remote (FAR). ※ The general program is called by debug, so use INT 20 returns. For programs called with the CALL instruction, RET must be changed. ※ Returning the instruction RET transfer control to the address specified by the stacking top, and the address is placed in the Call instruction called this program. ; ***************************************************************** DECIHEX segment; dECIHEX - Main Program assume cs: decihex repeat: call decibin; keyboard to binary call crlf; print cr and lf call binihex; binary to screen call crlf; print cr and lf jmp repeat; do it again; ---- ------------------------------------------ Decibin Proc Near; Procedure To Convert dec ..........; on keybd to binary and decibin endp; Left results in bx; ---------------------- -------------------------- BiniHex Proc Near; Procedure to Convert bin ............; Number In BX TO Hex on BiniHex Endp; Console Screen; ------------------------------------------------------------------------------------------------------------------------------------------------------------ ------ CRLF PROC NEAR; Procedure to Print ............; carriage returnid; and linefeed; ---------------- -------------------------------- DeciHex Ends; ************** ******************************** * End ※ Call instructions are used to call a subsystem and will control The right is transferred to the subscriber site in the computational element, and the next instruction address of the CALL is set to "return to the address" and stored in the stack. ※ Call can be divided into proximeces (NEAR) and remote (FAR): 1.NEAR: IP The contents of the status are placed in a stack. Used in the program and the program in the same memory segment. 2.FAR: CS The contents of the Scverals and the IP Terrace are stored in the stack in sequence. Used in the program and the program in different memory segments. ※ Discuss the better process of combined language programming, hoping to lay the foundation of your independent design, and how to use the tempering concept to design the program, you will rely on you to exercise hard, you will see more, just more Related books, you will have more application skills obtained from the examples, I wish you success. The end is over! ! Gooor2005-4-15