(This is the older material - click here - for current specification content)

3. Compiler

The previous page described the role of machine code. And also how difficult it is to write at that low a level. So high-level computer languages were developed.

The programmer will choose to use a certain computer language with which to write code. For example they may favour the language C++ or they may choose BASIC. In either case the programmer writes a series of statements to form his computer program.

These statements are called 'source code'.

The purpose of a 'compiler' is to translate source code into machine code.

The code a compiler generates is stored as an 'executable file'. Another name for an executable file is the 'object file', (not a generally popular term but your exam question may mention it). When this file is run, the machine code commands that it contains begin to be processed by the CPU.

In the Windows operating system, executable files have the .exe extension. For example, 'notepad.exe' is an executable file.

The previous page mentioned that every CPU has a different set of machine codes. And so the compiler will need to have the target CPU defined before it can carry out the translation.

For example, you can purchase C++ commercial compilers that can target the Intel x86 family of processors.

Intel have made sure that even code written for one of their earliest CPUs (the Intel 8086, introduced 30 years ago) can run on their most modern chips. Hence the term x86 denoting that the compiler will produce code that can run on any of the Intel chips (obviously you cannot expect an ancient 8086 CPU to run Core 2 Duo machine code, but you can assume the reverse, this is called 'backwards compatability' and is a constant consideration in the software and electronics industry)


Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Compilers



Copyright © www.teach-ict.com