Assembly language--Baidu Encyclopedia

Source: Internet
Author: User

Assembly Language (assembly language) is a low-level language for computers, microprocessors, microcontrollers, or other programmable devices, also known as symbolic languages. In assembly language, a mnemonic (mnemonics) is used instead of the operation code of the machine instruction, with the address symbol (symbol) or label (label) instead of the address of the instruction or operand. In different devices, assembly languages correspond to different sets of machine language instructions, which are converted into machine instructions through the assembly process. Generally speaking, the specific assembly language and the specific machine language instruction set is one by one corresponding, the different platforms can not be directly ported. [1] Many assembler provides additional support mechanisms for program development, assembly control, and auxiliary debugging. Some assembly-language programming tools often provide macros, which are also known as Macro assemblers. Assembly language is not widely used in program design like most other programming languages. In today's practical applications, it is often used on the ground floor, hardware operations and high-demand program optimization scenarios. Assembly language is required for drivers, embedded operating systems, and real-time running programs. [1]
Chinese name
Assembly
Foreign names
Assembly Language
Subject
Software
Generation Age
The 1950s
Compilation method
compilation
Directory
    1. 1 Development History
    2. 2 language Features
    3. ? General Features
    4. ? Advantages
    5. ? Disadvantages
    6. 3 Language Composition
    1. data transfer instruction
    2. integer and logical operation instruction
    3. shift instruction
    4. control transfer instruction
    5. string operation instruction
    1. ? input/Output Instructions
    2. 4 Related Technologies
    3. ? Assembler Series
    4. ? Compiling the Environment
    5. 5 Development Prospects
    6. 6 Practical Application
    1. 7 Classic Textbook
    2. ? x86 Processor
    3. ? arm and single chip microcomputer
Development course speaking of the production of assembly language, the first thing to say about machine language. Machine language is a collection of machine instructions. Machine instructions are the commands that a machine can execute correctly. The machine instruction of an electronic computer is a column of binary numbers. The computer turns it into a column of high and low levels so that the computer's electronic devices are driven and operated. The computer mentioned above refers to a machine that can execute machine instructions and perform operations. This is the concept of an early computer. In our common PC, there is a chip to complete the above mentioned computer functions. This chip is what we often call CPU (central processing unit, centralized processing unit). Each microprocessor, due to the different hardware design and internal structure, needs to be controlled by different level pulses to make it work. So each microprocessor has its own set of machine instructions, which is machine language. Early programming was using machine language. Programmers will use 0, 1 digital programming code to play on paper tape or card, 1 dozen holes, 0 do not punch, and then the program through the tape machine or card machine input computer, to do the operation. This machine language is composed of pure 0 and 1, very complex, inconvenient to read and modify, and prone to mistakes. Programmers quickly discovered the trouble of using machine language, they are difficult to identify and memory, to the development of the entire industry has brought obstacles, so the assembly language produced. Assembly language is the main body of assembly instructions. The difference between the assembly instruction and the machine instruction is in the representation method of the instruction. Assembly instruction is a written form of machine instruction that is easy to remember.
1234567 操作:寄存器BX的内容送到AX中1000100111011000              机器指令mov ax,bx                    汇编指令
Since then, programmers have used assembly instructions to write source programs. But the only thing a computer can readWork ProcessMachine instructions, how do you get the computer to execute programs written by programmers using assembly instructions? At this point, we need to have a translation program that translates assembly instructions into machine instructions, which we call compilers. The programmer uses assembly language to write the source program, then compiles it into machine code with the assembler compiler, which is finally executed by the computer. [2] Language features assembly language is directly oriented processor (PROCESSOR) programming languages. The processor is operating under the control of the instruction, and each instruction that the processor can recognize is called a machine instruction. Each processor has its own set of instructions that it can identify, called instruction sets. When the processor executes the instruction, it takes different actions according to different instructions and accomplishes different functions, which can change its internal working state and control the working state of other peripheral circuits. Another feature of assembly language is that the object it operates is not specific data, but registers or memory, which means that it is directly involved with registers and memory, which is why assembly language is faster than other languages, but this also makes programming more complex, since the data is stored in the storage or memory, then there must be an addressing method, that is, how to find the required data. For example, we can not use the data directly like the high-level language, but first we need to remove the data from the corresponding register ax and BX. This also increases the complexity of programming, because in high-level language addressing this part of the work is done by the compilation system, and in assembly language by the programmer himself, which adds to the complexity of programming and the readability of the program. Moreover, assembly language instruction is a symbol of the machine instruction, and different types of CPUs have different machine instruction system, there are different assembly languages, so, assembly language program and Machine have a close relationship. Therefore, in addition to the same series, different models of the CPU between the assembly language program has a certain degree of portability, other different types (such as minicomputer and microcomputer, etc.) between the CPU of the assembly language program is not portable, that is, the assembly language program is more general and portability than high-level language program low. Because assembly language has "machine-related" characteristics, programmers in assembly language programming, can be fully on the internal resources of the machine reasonable arrangement, so that they always in the best use of the state. This program executes code that is short and executes faster. Assembly language is the most closely related to hardware in all kinds of programming languages, the most direct one, in the efficiency of time and space is also the highest one, it is a University of higher learning Computer application technology, one of the major courses for training students to master programming technology, familiar with the machine operation and program debugging technology has important role [3] general features 1. Machine CorrelationThis is a low-level language for machines, usually designed specifically for a particular computer or series of computers. Because it is a symbolic representation of machine instructions, different machines have different assembly languages. The use of assembly language can be machine-oriented and give full play to the characteristics of the machine to obtain higher quality procedures. 2. High speed and efficiencyassembly language to maintain the advantages of machine languages, with direct and simple features, can effectively access and control the computer's various hardware devices, such as disk, memory, CPU, I/O port, etc., and take up less memory, fast execution speed, is an efficient programming language. 3. Complexity of writing and debuggingBecause it is the direct control hardware, and the simple task also needs a lot of assembly language statements, so in the program design must be all-encompassing, need to consider all possible problems, reasonable deployment and use of a variety of software and hardware resources. This inevitably adds to the burden on the programmer. In the same way, when the program debugging, once the program runs out of the problem, it is difficult to find. Advantage 1, because the assembly language design program is eventually converted into machine instructions, it is able to maintain the consistency of machine language, direct, simple, and can be like machine instructions to access, control the computer's various hardware devices, such as disk, memory, CPU, I/O port. With assembly language, you can access all the hardware and software resources that can be accessed. 2. Short target code, low memory consumption, fast execution speed, is an efficient programming language, often used in conjunction with high-level language, to improve the execution speed and efficiency of the program, to compensate for high-level language in the hardware control deficiencies, the application is very extensive. Disadvantage 1, assembly language is machine-oriented, at the bottom of the entire computer language hierarchy, it is considered a low-level language, usually for a specific computer or series of computers specifically designed. Different processors have different assembly language syntax and compilers, compiled programs can not be executed on different processors, lack of portability; 2, it is difficult to understand the program design intent from assembly language code, maintainability is poor, even the completion of simple work also requires a lot of assembly language code, it is easy to produce bugs, difficult to debug 3, the use of assembly language must be very familiar with a processor, and only for a specific architecture and processor optimization, development efficiency is very low, long and monotonous cycle. [3] Language composition data transmission instructions This part of the directive includes the general data transmission Instructions MOV, conditional delivery instruction Cmov cc, the stack operation instruction Push/pusha/pushad/pop/popa/popad, the exchange instruction Xchg/xlat/bswap, the address or the segment descriptor select the sub-routing directive LEA/LDS/LES/LFS/LGS/LSS, and so on. Note that CMOVCC is not a specific instruction, but rather a cluster of instructions, including a large number of instructions for determining whether or not to perform a specified transfer operation based on certain bit states of the EFlags register. Integer and logical operation instructions This part of the instruction is used to perform arithmetic and logic operations, including addition instruction ADD/ADC, subtraction instruction SUB/SBB, plus one instruction Inc, minus one instruction Dec, comparison operation instruction CMP, multiply instruction Mul/imul, Division command Div/idiv, The symbol extension instruction cbw/cwde/cdqe, the decimal adjustment instruction Daa/das/aaa/aas, the logic operation instruction Not/and/or/xor/test and so on. Shift instruction This part of the instruction is used to move the register or memory operand by the specified number of times. Includes the logical left-shift command SHL, the logical right-shift command SHR, the arithmetic left-shift instruction Sal, the arithmetic right-shift SAR, the circular left-shift instruction Rol, the cyclic right-shift instruction ROR, and so on. Bit operation instructions this part of the instruction includes the bit test instruction BT, bit test and set command BTS, bit test and reset instruction BTR, bit test and take the counter-instruction BTC, bit forward scan instruction BSF, bit backward scan instruction BSR, etc. Conditional setting directives this is not a specific instruction, but rather a command cluster, which includes approximately 30 instructions for setting a 8-bit register or memory operand based on some bit states of the EFlags register. Like Sete/setne/setge and so on. Control transfer Directives This section includes the unconditional transfer instruction JMP, conditional transfer Instruction J cc/JCXZ, cyclic instruction Loop/loope/loopne, Call of procedure invocation, subroutine return instruction ret, interrupt instruction Intn, INT3, into, iret, etc. Note that J ccis a command cluster that contains many instructions for deciding whether to transfer based on certain bit states of the EFlags register, and INT n is a soft interrupt instruction where n can be a number between 0 and 255, indicating the interrupt vector number. String operation instruction This part of the instruction is used to manipulate the data string, including the string transmission instruction Movs, the string comparison instruction CMPs, the string scan instruction scans, the string load instruction LODs, the string saves the instruction STOs, these directives may selectively use rep/repe/repz/ Repne and REPNZ are prefixed to continuous operation. Input/Output instructions This part of the instruction is used to exchange data with peripheral devices, including port input instruction In/ins, port output instruction Out/outs. Advanced Language Assistance DirectivesThis part of the instruction is convenient for compilers of high-level languages, including the creation of instruction enter for stack frames and the release of instruction leave for stack frames. control and privileged DirectivesThis section includes no operation instruction NOP, shutdown instruction hlt, wait instruction wait/mwait, code change command ESC, bus block command lock, memory range check instruction bound, global descriptor descriptor Operation Instruction LGDT/SGDT, interrupt descriptor Tabulation Operation Instruction Lidt/sidt, Local descriptor Lldt/sldt, descriptor segment bounds value loading instruction LSR, descriptor access read instruction Lar, Task Register operation instruction LTR/STR, request privilege level Adjustment command ARPL, task switch flag Clear 0 command CLTs, Control register and debug Register data transfer instructions MOV, cache control instruction INVD/WBINVD/INVLPG, model related register read and write instruction RDMSR/WRMSR, processor information acquisition instruction CPUID, timestamp read instruction RDTSC, etc. floating-point and multimedia instructionsThis part of the instruction is used to accelerate the operation of floating-point data, as well as single instruction multi-data (SIMD and extended ssex) instructions for accelerating multimedia data processing. This part of the instruction data is very large, can not be enumerated, please refer to the Intel Manual. virtual machine Extension DirectivesThis part of the directive includes Invept/invvpid/vmcall/vmclear/vmlaunch/vmresume/vmptrld/vmptrst/vmread/vmwrite/vmxoff/vmon and so on. [4] Related technology assembler typical modern Assembler Series(assembler) constructs the target code, which is a mnemonic (mnemonics) to the opcode (OpCode) and parses the symbol name (symbolic names) into the memory address and other entities. The use of symbolic references is an important feature of the assembler, which saves tedious and time-consuming calculations of manual forwarding when modifying programs. The basic is to turn the machine code into some letters, compile time and then replace the input instruction letter into obscure machine code. [1]  compilation environment with assembly language and other non-machine languages written symbols program known as the source program, the role of assembly language compiler is to translate the source program into the target program. The target program is a machine language program that can be processed and executed by the computer's CPU when it is placed in the pre-existing   position. The debug environment of the assembly is generally relatively small, and there are very few very good compilers. The compiler's choice depends on the type of target processor and the specific system platform. In general, a well-functioning compiler should be very convenient, for example, should be able to automatically organize the format, syntax highlighting, set compilation, linking and debugging as a whole, convenient and practical. For the widely used personal computer, can freely choose the assembly language compiler has MASM, NASM, tasm, Gas, FASM, radasm, etc., but most do not have debugging function. If it is to learn assembly language, easy to assemble because it has a perfect integration environment, is a very suitable for beginners compilation compiler. [1]  Development Foreground assembly language is the mnemonic of machine languages, which is easier to read and write than boring machine code, easy to debug and modify, and the excellent assembly language designers have been cleverly designed, which makes the code of assembler assembly faster than high-level language execution speed, accounting for less memory space and other advantages, However, assembly language running speed and space occupancy is for high-level languages and need to be cleverly designed, and some high-level languages in the post-compilation code execution efficiency is also very high, so this advantage slowly weakened. And in the writing of complex procedures have obvious limitations, assembly language depends on the specific models, can not be universal, and can not be transplanted between different models. Often said assembly language is a low-level language, not to say that assembly language to be discarded, on the contrary, assembly language is still a computer (or microcomputer) the underlying design programmer must understand the language, in some industries and areas, compilation is essential, not it is not applicable. Just, now the biggest domain of computer for it software, is also what we often say computer application software programming, in the hands of skilled programmers, the use of assembly language programming, the operating efficiency and performance than other languages written programs relatively improved, but the cost is to take longer to optimize, If the principle of computer and programming Foundation is not solid, but increase its development difficulty, it is not worth the candle, compared to the 2010 before and after the software development, is a market-oriented software industry, plus high-level language excellentand cross-platform, a company can not let a team use assembly language to write all things, spend several times or even dozens of times times, rather than using other languages to complete, as long as the final result is not much worse than the assembly language, it can be the first step to complete, which is the inevitable result of the market economy. However, so far, no programmer has dared to conclude that assembly language is not required to learn, at the same time, the assembly language (Assembly Language) is machine-oriented programming language, the design of skilled assembler programmer, part of the software has been developed from the development, in the industrial electronic programming. For the relatively small but hardware-based language design requirements of the industry, such as 4-bit microcontroller, due to its capacity and operation, the industry's electronic engineers generally responsible for the development of design circuits and software control, the main development of language is a compilation, C language use only a small part, and electronic development engineers are daughter difficult to seek, in some industrial companies , a core of electronic engineers than any other staff treatment is high, compared to the General electronic engineer treatment is more than 10 times times the programmer. This is because since 21st century, the study of the compilation of people although a lot, but really can learn to master but not much, it is difficult to learn compared to high-level language, difficult to use, the scope of application is small, although simple, but too flexible, learning high-level language of people to learn the assembly than the beginning to learn the assembly more difficult, But it is easy to learn the high-level language by the assembler, but it is difficult to simplify from the simple. For a comprehensive understanding of the microcomputer principle of the programmer, assembly language is the required languages. As modern software systems become more and more complex, a large number of high-quality packaged languages such as C/c++,pascal/object Pascal have emerged. These new languages enable programmers to be simpler and more efficient in the development process, enabling software developers to cope with rapid software development requirements. and assembly language because of its complexity makes its application areas gradually reduced. But that does not mean that the assembly is useless. Because the assembly is closer to the machine language and is able to operate directly on the hardware, the resulting program has a higher speed than other languages, consumes less memory, and is therefore used in a number of highly time-sensitive programs, core modules for many large programs, and industrial controls. [1]  In addition, although there are a number of programming languages to choose from, the compilation is still a required course for students majoring in computer science, so that students can understand the principles of how computers work. In history, assembly language was once one of the most popular programming languages. With the growth of software scale and the consequent requirements for software development progress and efficiency, high-level languages have gradually replaced assembly language. But even so, high-level languages can not completely replace the role of assembly language. With the Linux kernel, although most of the code is written in C, it is still unavoidable to use assembler code in some key places. Because of the relationship between this part of the code and the hardwareVery close, even C language will appear to be inadequate, and assembly language can be very good weaknesses, maximize the performance of hardware. First of all, most of the statements of assembly language directly correspond to the machine instructions, the execution speed, high efficiency, the code volume is small, in those memory capacity is limited, but need fast and real-time response of the occasion is more useful, such as instrumentation and industrial control equipment. Second, in the core part of the system program, as well as with the system hardware frequently dealing with parts, you can use assembly language. such as the core program section of the operating system, the initialization of the I/O interface circuit, low-level drivers for external devices, and frequently called subroutines, dynamic Connection libraries, some advanced drawing programs, video game programs and so on. Thirdly, assembly language can be used for software encryption and decryption, computer virus analysis and prevention, as well as program debugging and error analysis and other aspects. Finally, by learning assembly language, we can deepen the understanding of computer principles and operating systems and other courses. Through learning and using assembly language, can perceive, realize and understand the logical function of the machine, upward to understand the principles of various software systems, lay the foundation of technical theory; down to master the principle of hardware system, lay the foundation of practical application. The classical Textbook assembly language teaching materials are many, all kinds of processors are involved, rough statistics no more than hundred kinds. In so many textbooks, the use of more can be categorized as follows: X86 processor 1. "X86 assembly language: From the actual mode to the protection mode", Li Zhong, electronic industry press, 2013-1. Based on the Intel x86 processor, the NASM compiler, and the Bochs virtual machine. The language of the processor, in this sense, since learning assembly language, it must be directly oriented to hardware programming, rather than the use of inexplicable DOS interrupts and API calls. This is an interesting book, it does not spend the space to calculate some boring math problems. Instead, it teaches you how to control your hardware directly, display characters without the help of BIOS, DOS, Windows, Linux, or any other software support, read hard disk data, control other hardware, and more. We know that 32-bit and 64-bit are mainstream, real-mode and DOS operating systems have become history, and both Linux and Windows are working in protected mode. This book is about 32-bit protection, especially the 32-bit protection model, and reading this book is very helpful in understanding how modern computers and modern operating systems work. 2. "Assembly Language" (2nd edition), Wang Shuang, Tsinghua University Press, 2013-4-1 based on the Intel 8086 processor, MASM compiler, and the DOS platform of the compilation of teaching materials, fully 8086 processor real mode, not involving the common 32-bit and 64-bit mode, but because easy to understand , the reader reflects very well. 3.80x86 assembly Language Programming tutorial, Yang Ziwen, Tsinghua University Press, 1999-3-1In the Intel x86 processor, MASM, and Tasm compilers, contains 16-bit real mode and 32-bit protected mode content, and the latter is described in more detail. 4. "32-digit assembly language Program Design", Chanxiaojie, mechanical industry Press, 2011-8-1 based on the Intel x86 processor, MASM compiler, and the Windows platform for the compilation of teaching materials. 5. "16/32-bit microcomputer principle assembly language and interface Technology", Chanxiaojie, Chen Tao, mechanical Industry Press, 2005-2-1 based on the Intel x86 processor, discusses the basic principles of 16-bit microcomputer, assembly language and interface technology, and leads to 32-bit microcomputer system related technology. 6. "Intel Assembly Language Program Design" (fifth edition), Owen, electronic industry publishing house, 2012-7-1 based on the Intel x86 processor, MASM compiler, and dos/windows platform of the compilation of textbooks, there are 16 real-mode content, There are also 32-bit protected mode content. 7. "Programming Art of Assembly Language" (2nd edition), Hyde, Tsinghua University Press, 2011-12-1 based on the Intel x86 processor, using the author's homemade Advanced language assembler (High level Assembler,hla) as a teaching tool, To gain the advantages and functionality of a high-level language in some way. 8. "X86 PC assembly language, design and Interface" (fifth edition), Mazdi, chosigt, electronic industry press, 2011-1-1 based on the Intel x86 processor, not only 16 real-mode content, but also about the 32-bit protection mode of the content, 64-bit also has introduced. Arm and microcontroller 1. "Assembly language Program design-based on ARM Architecture" (2nd edition), Wen Quangang, Beijing University of Aeronautics and Astronautics Press, 2010-8-1 based on ARM architecture processor, is learning embedded technology introductory materials. 2. "0 basic AVR MCU", Xu Yimin and other authoring, mechanical industry press, 2011-1-1 monolithic microcomputer overview, AVR microcontroller development tools, AVR microcontroller C language, ATMEGA16 microcontroller basic structure, AVR command system and assembly system. 3. MULTISIM10-based 51 single-chip computer simulation actual combat course, Niedeng, Ding Wei Editor, electronic Industry Press, 2010-2-1 elaborated NI Multisim 10 in the monolithic computer simulation each main function. 4. PIC18 Microcontroller: Architecture, programming and Interface design, (US) Berry, Tsinghua University Press, 2009-4-1 microcontrollers are widely used in automobiles, home appliances, industrial control, medical equipment and many other fields. This book takes Microchip's PIC18 series microcontrollers as an example to fully explain how to program a microcontroller using C and assembly language. 5. TheCASL assembly Language Program design, Zhao Lihui authoring, China Electric Power Press, 2002-10-1CASL assembly language is China's computer software professional technical qualification and level examination of advanced programmer level must test content. This book is about CASL assembly language Program design monographs.

Assembly language--Baidu encyclopedia

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.