You are on page 1of 1

Low level languages such as Assembly need to be converted to binary to be read by

the computer. A command in assembly is called a ‘mnemonic’, and each one usually
has a direct equivalent in machine code. Assemblers produce CPU-specific machine
code.

There are two ways high level languages can be converted to machine code: they can
be either compiled or interpreted.

Interpreters work by converting the source code one line at a time, this means that
you can type a command into the Python command line and it will be run immediately.
However, interpreters sometimes convert source code into an intermediate
‘bytecode’, which is ran on a virtual machine – this insulates the computer from
defective code and ensures it won’t crash. An example of this is Java, which is
interpreted into bytecode, which is then run by the Java Virtual Machine.
Interpreters are usually slower than compilers.

Compilers work by converting source code into machine code all at once. Languages
such as C++ are compiled directly into binary by the compiler, and then stored in
an object file. One or more object files are combined to form the final executable
file. A compiler follows three steps: lexical analysis (identifies keywords and
operators), syntax analysis (ensuring the source code follows the language’s
syntax) and code generation (producing the machine code to be as fast and memory
efficient as possible). If a program contains many object files as well as in-built
libraries, an application called a linker is used to create the final executable
file. The same source code can be run through a different compiler to generate
machine code for a different CPU, this means you don’t need to re-write code for
different CPUs.

You might also like