language The representation of a
computer program that is read and interpreted by the computer hardware (rather than by some other machine code program). A program in machine code consists of a sequence of "instructions" (possibly interspersed with data). An instruction is a binary string, (often written as one or more
octal,
decimal or
hexadecimal numbers). Instructions may be all the same size (e.g. one 32-bit word for many modern
RISC microprocessors) or of different sizes, in which case the size of the instruction is determined from the first
word (e.g.
Motorola 68000) or
byte (e.g. Inmos
transputer). The collection of all possible instructions for a particular computer is known as its "
instruction set".
Each instruction typically causes the
Central Processing Unit to perform some fairly simple operation like loading a value from memory into a
register or adding the numbers in two registers. An instruction consists of an
op code and zero or more
operands. Different processors have different instruction sets - the collection of possible operations they can perform.
Execution of machine code may either be
hard-wired into the
central processing unit or it may be controlled by
microcode. The basic execution cycle consists of fetching the next instruction from
main memory, decoding it (determining which action the
operation code specifies and the location of any
arguments) and executing it by opening various
gates (e.g. to allow data to flow from main memory into a CPU
register) and enabling functional units (e.g. signalling to the
ALU to perform an addition).
Humans almost never write programs directly in machine code. Instead, they use
programming languages. The simplest kind of programming language is
assembly language which usually has a one-to-one correspondence with the resulting machine code instructions but allows the use of
mnemonics (ASCII strings) for the "op codes" (the part of the instruction which encodes the basic type of operation to perform) and names for locations in the program (branch labels) and for
variables and
constants. Other languages are either translated by a
compiler into machine code or executed by an
interpreter (2009-06-16)