Difference between: Opcode, byte code, mnemonics, machine code and assembly

后端 未结 6 1499
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-12 12:35

I am quite new to this. I tried to understand the difference between the mentioned terms in a clear fashion, however, I am still confused. Here is what I have found:

6条回答
  •  难免孤独
    2020-12-12 12:40

    The following line is a disassembled x86 code.

    68 73 9D 00 01       PUSH 0x01009D73
    

    68 is the opcode. With the following for bytes it represents PUSH instruction of x86 Assembly language. PUSH instruction pushes 4 bytes (32 bits) length data to stack. The word PUSH is just a mnemonic that represents opcode 68. Each of bytes 68, 73, 9D, 00, 01 is machine code.

    machine codes are for real machines (CPUs) but byte codes are pseudo machine codes for virtual machines.

    When you write a java code. java compiler compiles your code and generates byte codes. (A .class file) and you can execute the same code at any platform without changing.

                         JAVA CODE
                             |
                             |
                         BYTE CODE
             ________________|_______________
             |               |               |
          x86 JVM        SPARC JVM        ARM JVM
             |               |               |
             |               |               |
            x86            SPARC            ARM
       MACHINE CODE     MACHINE CODE    MACHINE CODE
    

提交回复
热议问题