Process Analysis of computer executing program code

Source: Internet
Author: User

Classification of computer languages:

The classification of computer language can be divided into three categories: machine language, assembly language and high-level language .

Machine language:

The computer can directly execute the machine language, composed of binary code, can directly operate on the hardware, for people, very difficult to write.

Assembly:

Assembly language is the same as the machine languages, are directly to the hardware operation, the use of abbreviations in English. It is also necessary for us to write down the specific actions of each step in a language that is more complex (compared to the high-level language, but certainly much better than the machine language).

Advanced Language:

High-level language is a lot of machine instructions to merge, remove a lot of details, greatly simplifying the program, the programmer's requirements are much lower. Now common C,c++,java and so on language, all belong to the high-level language. However, high-level languages cannot operate directly on the hardware.

Take a look at a few more concepts.

Compilation, compilation process, interpretation, scripting, interpretive language, compiler-type language.

Because computer intelligence reads machine language, assembly and high-level languages must be transformed into machine language by some column processing.

For assembly language, this conversion process, is through the assembly process, the assembly language into machine language, the process of becoming a compilation.

For high-level languages, it is through the compilation process that it translates into machine language. (In fact, it was compiled into assembly language, and then the process of conversion from assembler to machine language) is generally performed by compilers.

compiler translation process, in fact, is divided into two types of compilation and interpretation .

Compile is for the high-level language, one-time conversion to the executable machine language, and then execute (there is no compiler when the implementation of what happened);

The explanation, which is equivalent to one side of the transformation, runs on one side, does not generate executable files in the middle, and each time it runs, it needs to be re-interpreted again. Unlike compilation, it can be compiled once, no matter how many times it is executed no longer (the code does not change).

Literally, the language that is executed by compiling is a compiled language that is interpreted to run by interpreting the line language. The explanatory language has its own interpreter.

The Java language we did not say above, it should not be the standard compiler type is not the standard interpretation type.

Java also needs to be compiled, but it is compiled into a Java bytecode file, equivalent to the machine code that can be run directly on JAVAVM (virtual machine). This bytecode file is then run in the form of an explanation, that is, for the byte code, through the interpreter, to compile a sentence, run a sentence.

The Java interpreter, which is quite a feature of the Javavm.java language, also forms its cross-platform advantage, with Java bytecode making "write once, run everywhere". It can be run as long as the Java Virtual machine is installed on the platform. In fact, I didn't quite understand it before, because other compiled languages can be compiled once and run multiple times. And not as cumbersome as Java, but also to run on a Java virtual machine. Now, it is this kind of trouble that makes cross-platform features, because the binary machine code that is compiled directly from other languages is not necessarily adaptable to all platforms. Java bytecode can be run as long as you can install a Java Virtual machine platform. (In a Web program, a browser that can run Java is also considered a JAVAVM instance).

In a word, other languages run directly on the hardware platform, while Java is on a purely software platform running on a hardware platform.

C, c + + program compilation process:

to illustrate the process of compiling the program, we use the classic Hello World program as an example:

#include <stdio.h>int main (intcharConst *argv[]) {    printf ( " Hello World!!! \ n")    ; return 0 ;}

In a Linux system, we use the GCC compiler to compile the source program file HELLOWORLD.C into the executable target file HelloWorld.

[Email protected]:~/test_code$ gcc helloworld.c-o hello[email protected]:~/test_code$./Hellohello World !!!

This process passes through four stages, namely the preprocessing phase, the compilation phase, the compilation stage and the link stage. The program that executes this four phase is a preprocessor, a compiler, a assembler, and a linker, which together make up the compilation system.

• Preprocessing phase: the preprocessor (CPP) adds the contents of the header file to the source program according to the header file contained in the ' # '. Get the new program file text with ". I" for the file name extension. For example, the HelloWorld program contains the stdio.h header file, which plugs the contents of the header file into the source program.
• Compile stage: The compiler (CCL) translates the text file hello.i into the assembler Hello.s. That is, the translation of high-level languages into assembly code, low-level machine language instructions.
• Assembly stage: Assembler (AS) will assemble the program hello. s translates into machine instructions, packages these instructions into a format that can relocate the target program, and saves the results in the hello.o file, hello.o is a binary file.
• Link stage: the linker (LD) will combine all the. o File links in a project into an executable target file that can be loaded in memory and run by the system.

The above is the C,c++ program compilation process;

System Hardware Composition:

System Hardware Composition:

The program has a tendency to access data and code in the local area. Most of the memory operations are done in a fast cache by storing potentially frequently accessed data in the cache, and the program performance is greatly improved.

Operating System Management hardware:

In the processor, the instruction set structure is the abstraction of the actual processor hardware, in the operating system, the file is the abstraction of I/O, the virtual memory is the abstraction of the program memory, the process is the

An abstraction of a running program, a virtual machine is an abstraction of the entire computer (including the operating system, processors, and programs)


• Heap: The heap can dynamically expand and contract when it is run, such as when a malloc or free function is called.

• Shared libraries: Around the middle of the address, to store code and data regions that are shared like the C standard library or math library.

• Stack: The stack is located at the top of the user's virtual address space, and the compiler implements the function call with it. As with heaps, you can dynamically scale and contract while the program is running. Each call function, the stack grows, the function returns, and the stack shrinks.

• Kernel Virtual storage: The stack is located at the top of the user's virtual address space, and the compiler implements the function call with it. As with heaps, you can dynamically scale and contract while the program is running. Each call function, the stack grows, the function returns, and the stack shrinks.

Process Analysis of computer executing program code

Related Article

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.