What is the actual relation between assembly, machine code, bytecode, and opcode?

前端 未结 6 879

What is the actual relation between assembly, machine code, bytecode, and opcode?

I have read most of the SO questions about assembly and machine code, such as this,

6条回答
  •  清酒与你
    2020-12-29 12:33

    Assembly: Human readable instructors to the assembler + data bytes + operators

    Machine code: The actual bit sequences that the CPU understands.

    It contains:

    • the opcode,
    • which registers to use,
    • offset from the PC register,
    • and similar info

    Bytecode: This is the code read by a interpreter (most implementations of java are actually an interpreter that reads bytecode and uses that bytecode to select a sequence of machine code to have the CPU actually execute). Bytecode is often used to make the same source code work on several different CPUs.

    Opcode: The first one (or two) bytes of the machine code. It acts like a selector to tell the CPU which microcode sequence the CPU it is to perform (something like a switch statement in C)

    Microcode: The hardwired instruction sequences within the CPU that are used to execute the machine code.
    There are lots of microcode sequences, at least one sequence for each opcode. In general, the rest of the machine code is just parameters to the microcode sequence that is selected by the opcode each microcode sequence contains instructions to open/close gates, clock data, pass info to/from the accumulator, etc

提交回复
热议问题