"Assembly Language" Summary 01

Source: Internet
Author: User

(a) The process from writing to execution of a source program

    1. Compiling the compilation source program

    2. To compile a connection to the source program

    3. Execute a program in an executable file

The operating system loads the machine code and data in the executable file into memory according to the description information in the executable file, and initializes the relevant initialization (such as setting Cs:ip to the first instruction to be executed), and then executes the program by the CPU.

(ii) SOURCE program

  1. Pseudo-directive: in the Assembly, there are two kinds of instructions, one is the assembly instruction, the other is a pseudo-instruction. The assembly instruction has a corresponding machine code instruction, which can be compiled into a machine instruction and eventually executed by the CPU. and the pseudo-directive does not have the corresponding machine instruction, finally does not be executed by the CPU, then who executes the pseudo-instruction? Pseudo-directives are instructions that are executed by the compiler. Segment and ends are pairs of pseudo-directives, which are a pair of pseudo-instructions that must be used when writing a assembler that can be compiled. Its function is to define a segment, segment describes the beginning of a segment, ends describes the end of a segment, a segment must have a name to identify.

    A assembler is made up of multiple segments that are used to hold code, data, or as a stack space.
    End is an assembly end tag, the compiler in the compilation source program, if the pseudo-instruction end encountered, the end of the compilation of the source program, note that end and ends,ends is used in pairs with segment, marking the end of a segment, the meaning of ends can be understood as " End segment ". The purpose of our end here is to mark the end of the entire program.

    assume the meaning of this pseudo-directive is "hypothesis". It is assumed that a section of a register and a program are associated with a segment defined in Segment...ends.

  2. "Program" in the source program: Simple point, all content in the source program file is the source program.

  3. Program return: Instruction mov 4c00h int 21h, the function that the two instruction implements is the return of the program

    Objective Related directives Directive Nature Directive performer
    Notifies the compiler that a segment ends Segment name ends Pseudo-directive At compile time, executed by the compiler
    Notifies the compiler that the program has ended End Pseudo-directive At compile time, executed by the compiler
    Program returns mov ax,4c00h int 21h Assembly Instructions Performed by the CPU when executed

(iii) Compilation and connection

ignores list files (. LST) build, cross-reference file (. CRF) file generation.

Ignores image files when connecting (. MAP) generated, the library file (. LIB) file generation, if not linked to other libraries

(iv) Follow-up process of program execution

Loading process for. exe files in a DOS system

    1. Find an adequate amount of free memory area with a starting address of sa:0000(that is, an offset address of 0 for the starting address).

    2. In the first 256 bytes of this memory area, a data area called the program segment prefix (PSP) is created, and DOS uses the PSP to communicate with the loaded program.

    3. Starting at 256 bytes of this memory area (behind the PSP), the program is loaded and the program's address is set to sa+10h:0.

    4. The segment address of the memory area is stored in DS , and after the other related registers are initialized, set the cs:ip point to the program's entry.

Summary completed.

This article is from the "where No Play" blog, please be sure to keep this source http://liaofan.blog.51cto.com/12295212/1917396

"Assembly Language" Summary 01

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.