Assembly code vs Machine code vs Object code?

后端 未结 10 1981
执笔经年
执笔经年 2020-11-27 09:11

What is the difference between object code, machine code and assembly code?

Can you give a visual example of their difference?

10条回答
  •  余生分开走
    2020-11-27 09:36

    Source code, Assembly code, Machine code, Object code, Byte code, Executable file and Library file.

    All these terms are often very confusing for most people for the fact that they think they are mutually exclusive. See the diagram to understand their relations. The description of each term is given below.



    Source code

    Instructions in human readable (programming) language


    High-level code

    Instructions written in a high level (programming) language
    e.g., C, C++ and Java programs


    Assembly code

    Instructions written in an assembly language (kind of low-level programming language). As the first step of the compilation process, high-level code is converted into this form. It is the assembly code which is then being converted into actual machine code. On most systems, these two steps are performed automatically as a part of the compilation process.
    e.g., program.asm


    Object code

    The product of a compilation process. It may be in the form of machine code or byte code.
    e.g., file.o


    Machine code

    Instructions in machine language.
    e.g., a.out


    Byte code

    Instruction in an intermediate form which can be executed by an interpreter such as JVM.
    e.g., Java class file


    Executable file

    The product of linking proccess. They are machine code which can be directly executed by the CPU.
    e.g., an .exe file.

    Note that in some contexts a file containing byte-code or scripting language instructions may also be considered executable.


    Library file

    Some code is compiled into this form for different reasons such as re-usability and later used by executable files.

提交回复
热议问题