Novice must see-assembly language Super Enrichment Course

Source: Internet
Author: User
Tags arithmetic modify relative

"Oh, man, what's the compilation?" It's useless, brother. Use VB "Fishing" an API is enough for you to work a 10-day and a half month, still not necessarily get out. "This gentleman's speech is not empty, then we still have no need to grind him to investigate?" (Nonsense, of course!) Why else would you write this article? Don't worry, don't worry, let me take the whole story slowly: one, all computer language written program in memory are stored in the machine code mode, machine code can be more accurate translation into assembly language, this is because the assembly language compatibility is best, so almost all tracking, debugging tools (including win95/ 98) are compiled by the assembly, if you are interested in crack ... Second, the Assembly directly with the hardware, if you want to straightened program in the implementation of the computer in the context, that is to understand what each component of the computer is doing, exactly how to do? A real hardware enthusiast, it's not possible to understand these. Three, now play DOS is more "master", if can like me to mix (I am not a master) "master" inside, not only from the "master" friends there to set some hacker-level "confidential", but also the self-proclaimed "master" to enjoy a strong sense of vanity--#$%& "wake up!"

For beginners, many of the commands in the compendium are too complex to be studied for a long time and can not write a beautiful procedure, which hinders our interest in learning the compilation, and many people give up on this. So my personal view of the compilation, not necessarily to write programs, writing program is not the strength of the assembly, you may wish to play debug, sometimes crack out a small software than complete a program more sense of achievement (like learning to play the computer first game). Some advanced instructions are actually useful only to experienced assembler programmers, which is too advanced for us. To make learning assembly language a good place to start, you must first eliminate those ornate and complex commands and focus on the most important commands (CMP LOOP MOV jnz ...). )。 But I want to be in the book of the textbooks to complete the above goals, it is difficult, so I sorted out the super concentration (with WinZip, WINRAR ...) Oppression in turn, hehe! Tutorial The boast of saying, see through this article, you can "inadvertently" between the predecessor or the epigenetic show off debug, very fulfilling, try! So--what's the next thing? ――here We go! (Reading does not understand does not matter, the following must be decomposed)

Because the assembly is talking to the hardware through CPU and memory, we have to understand the CPU and memory first: (on the number of the issue of the system does not mention)

CPU is a chip that can perform all arithmetic/logic operations and basic I/O control functions on a computer. An assembly language can only be used for a specific CPU. In other words, different CPUs in the assembly language instruction syntax is not the same. PC from 1981 to date, its CPU development process: 8086→80286→80386→80486→pentium→ ..., as well as AMD, Cyrix and other offshoot. Behind the compatibility of the previous CPU functions, but more instructions (such as more Pentium MMX instruction set), increased register (such as 386 of the 32-bit eax), increased the register (such as 486 FS). To ensure that the assembler can be applied to a variety of models, it is recommended to use 8086 assembly language, the best compatibility. All of this paper is 8086 assembly language. Register (register) is a component within the CPU, so data transfer between registers is very fast. Usage: 1. Can perform arithmetic and logical operations on data in registers. 2. Addresses stored in registers can be used to point to a location in memory, that is, addressing. 3. A peripheral device that can be used to read and write data to a computer. 8086 has 8 8-bit data registers, the 8-bit registers can be composed of 16-bit registers: Ah&al=ax: Cumulative registers, often used for operations; BH&BL=BX: base register, often used for address indexing; CH&CL=CX: Counting registers, often used for counting ; DH&DL=DX: Data registers, often used for data delivery. In order to use all the memory space, 8086 set up four segment registers, specially uses to save the segment address: CS (code Segment): the snippet Register; DS (Data Segment): segment register; SS (Stack Segment): Stack segment Registers ; es (Extra Segment): Additional segment registers. When a program is to be executed, it is necessary to determine where the program code, data, and stack are to be used in memory, and to point to these starting positions by setting the segment register CS,DS,SS. Typically, the DS is fixed and the CS is modified as needed. Therefore, the program can be written in any size with an addressable space of less than 64K. So the size of the program combined with its data is limited to the 64K that the DS refers to, which is why the COM file must not be greater than 64K. 8086 as a battlefield, register as a military base to speed up work. In addition to the registers mentioned above, there are some special features of the Register: IP (intruction pointer): instruction pointer register, with CS, can track the execution of the program; SP (stack pointer): Stack pointers, used with SS, You can point to the current stack location. BP (base pointer): Base point pointer Register,Can be used as a relative base location for SS; SI (source Index): The original variable address register can be used to store the source-variable pointer relative to the DS segment; DI (Destination Index): A destination variable register that can be used to hold the target variable pointer relative to the ES segment. There is also a flag register fr (Flag register), which has nine meaningful flags, which are described in detail later in this article.

Memory is a key part of the computer's operation, and it is where the computer stores information at work. The memory organization has a number of stored locations, called addresses, that can hold numeric values. 8086 address Bus has 20 bits, so the CPU has up to 1M of addressing space, which is the effective control of DOS, and 8086 can do is limited to processing 16-bit data, that is, only 0 to 64K, so you must use segmented addressing to control the entire memory address. Complete 20-bit addresses can be divided into two parts: 1. Segment Base Address (Segment): 16-bit binary number followed by four binary 0, that is, a 16 into 0, into a 20-bit binary number, you can set any 64K paragraph 1M, usually recorded as 16-bit binary; 2. Offset : Use the 16-bit binary number directly to point to any one of the addresses in the segment base address. such as: 2222 (segment Base): 3333 (offset), its actual 20-bit address value is: 25553. In addition to the above nutrients to fully absorb, you also need to know what is DOS, BIOS function calls, simply, the function call is similar to the WIN95 API, the equivalent of subroutines. Assembly Writing program is enough to kill, if you do not use MS, IBM's subroutine, this day is really impossible to cross (about the function call in the "Computer Enthusiasts" 98 11).

There are two main ways to write assembly language: 1. Use compilers such as MASM or TASM, 2. Use the debugger debug.com. Debug is not really a compiler, its main purpose is debugging, that is, correcting errors in the assembler. However, it can also be used to write short assembler programs, especially for beginners, and DEBUG is the best getting started tool. Because the debug operation is easy: just type debug carriage return, a carriage return can be assembled, the process is simple, while using the compiler, you must use a text editor, compiler itself, link and exe2bin programs, each of which must use a series of fairly complex commands to work, and using the compiler to process the source program, you must add a number of directives unrelated to the directive statements for the compiler to identify, using DEBUG to avoid the beginning of the encounter many difficult to understand the line of the program. In addition to being able to assemble programs, debug can be used to check and modify memory locations, load storage and execute programs, and check and modify registers, in other words, Debug is designed to make us touch hardware. (8086 common instruction usage will be explained in each assembler, limited to space, it is impossible to list all instructions).

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.