Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between assembly code and bytecode?

While in the search for the various differences in the meanings of source code, bytecode, assembly code, machine code, compilers, linkers, interpreters, assemblers and all the rest, I only got confused on the difference between bytcode and assembly code.

Particularly the introduction this wikipedia article to describe CIL confused me since it seems to use both terms (assembly code and bytecode) interchangeably making me think they might mean exactly the same.

like image 806
Aaron Gusman Avatar asked Nov 23 '09 11:11

Aaron Gusman


People also ask

Is byte code assembly code?

Bytecode is something like an assembly language. It's not a real assembly language. The Java Virtual Machine then "runs" this fake assembly language, effectively translating it to a real assembly language.

What is difference between bytecode and machine code?

Byte code is a non-runnable code generated after compilation of source code and it relies on an interpreter to get executed. Machine code is a set of instructions in machine language or in binary format and it is directly executed by CPU.

What is difference between intermediate code and bytecode?

Both of these are codes that act as a set of instructions that help machines/ devices behave in a specified manner or perform certain operations/ tasks. The primary difference between byte code and machine code is that bytecode is an intermediate code while the machine code is the final code that the CPU processes.

Is bytecode translated to assembly?

Bytecode is kind of like assembly. And the JIT produces machine code (also like assembly). Neither is actually an assembler or assembly language. jvm input = bytecode (platform independent) , jvm output = binary code for target architecture.


2 Answers

Assembly code normally does mean the human readable form of a machine's native language (the so-called machine language). Byte code on the other hand is normally a language that can be interpreted by a byte code interpreter — so it is not the processor's native language.

Why the confusion then? You can't compare Assembly language versus Byte code this way. Of course a byte code can also have an assembly code — meaning a human readable form of it, because "Assembly language" does not necessary mean that it is for a real machine — but it is a human readable form of some native language — for processors, this native language is the machine code — but you also can have assembly code of a pseudo-(or interpreted) machine like Bytecode.

See also: Assembly Language

Further distress comes of course — like you can see in all the discussion here — because IT people (also myself) tend to be lax in wording. "Assembly language" is often used when speaking about machine code. This of course is not totally correct, because Assembly Language is only the human readable form of some machine's code.

like image 64
Juergen Avatar answered Sep 22 '22 23:09

Juergen


I remember that since the begining of microcontrollers and microprocessors the word Assembly was used to designate the machine code in a human readable way. It seems to me that Microsoft has caused confusion by using the same word "Assembly" to name what would be the ByteCode produced by their dotNET Framework compilers. So in this case I'd say that what "Bytecode" means to the Java runtime is similar to what this new use of the word "Assembly" means for Microsoft dotNET runTime environment. Am I wrong to assume that?

like image 26
Ade_Oliv Avatar answered Sep 20 '22 23:09

Ade_Oliv