Java Reference
In-Depth Information
1.3 Translating Human-Readable Programs to Machine
Code
On the most basic level, computer instructions are extremely primitive. The processor
executes machine instructions. CPUs from different vendors, such as the Intel Pentium
or the Sun SPARC, have different sets of machine instructions. To enable Java
applications to run on multiple CPUs without modification, Java programs contain
machine instructions for a so-called ȒJava virtual machineȓ (JVM), an idealized CPU
that is simulated by a program run on the actual CPU. The difference between actual
and virtual machine instructions is not importantȌall you need to know is that
machine instructions are very simple, are encoded as numbers and stored in memory,
and can be executed very quickly.
Generally, machine code depends on the CPU type. However, the instruction set of
the Java virtual machine (JVM) can be executed on many CPUs.
8
9
A typical sequence of machine instructions is
1. Load the contents of memory location 40.
2. Load the value 100.
3. If the first value is greater than the second value, continue with the instruction
that is stored in memory location 240.
Actually, machine instructions are encoded as numbers so that they can be stored in
memory. On the Java virtual machine, this sequence of instruction is encoded as the
sequence of numbers
21 40
16 100
163 240
When the virtual machine fetches this sequence of numbers, it decodes them and
executes the associated sequence of commands.
How can you communicate the command sequence to the computer? The most direct
method is to place the actual numbers into the computer memory. This is, in fact, how
Search WWH ::




Custom Search