7 FG
7 FG
Sarangi
Programmers typically write programs in a high level language such as C or JavaTM . These
languages contain complex constructs such as structures, unions, switch-case statements, classes
and inheritance. These concepts are too complicated for a computer to handle. Hence, it is
necessary to pass a C or C++ program through a dedicated program called a compiler that
can convert it into a sequence of basic instructions. A compiler effectively removes the burden
of creating machine (computer) readable code from the programmer. The programmer can
concentrate only on the high level logic. Figure 1.5 shows the flow of actions. The first step
is to write a program in a high level language (C or C++). Subsequently, the second step
involves compiling it. The compiler takes the high level program as input, and produces a
program containing machine instructions. This program is typically called an executable or
binary. Note, that the compiler itself is a program consisting of basic machine instructions.
compile execute
Program Executable Output
Let us now come to the semantics of instructions themselves. The same way that any
language has a finite number of words, the number of basic instructions/rudimentary commands
that a processor can support have to be finite. This set of instructions is typically called the
instruction set. Some examples of basic instructions are: add, subtract, multiply, logical or,
and logical not. Note that each instruction needs to work on a set of variables and constants,
and finally save the result in a variable. These variables are not programmer defined variables;
they are internal locations within the computer. We define the term instruction set architecture
as:
Definition 3
The semantics of all the instructions supported by a processor is known as the instruction
set architecture (ISA). This includes the semantics of the instructions themselves, along
with their operands, and interfaces with peripheral devices.
The instruction set architecture is the way that software perceives hardware. We can think
of it as the list of basic functions that the hardware exports to the external world. It is the,
“language of the computer”. For example, Intel and AMD CPUs use the x86 instruction set,
IBM processors use the PowerPC R instruction set, HP processors use the PA-RISC instruction
set, and the ARM processors use the ARM R instruction set (or variants of it such as Thumb-1
and Thumb-2). It is thus not possible to run a binary compiled for an Intel system on an ARM
based system. The instruction sets are not compatible. However, in most cases it is possible
to reuse the C program. To run a C program on a certain architecture, we need to procure a
compiler for that specific architecture, and then appropriately compile the C program.