Programming and Problem Solving with Java

(やまだぃちぅ) #1
1.2 How Is Java Code Converted? | 11

Instructions in an assembly language are in an easy-to-remember form called
amnemonic(pronounced “ni-’män-ik”). Typical instructions for addition and sub-
traction might look like this:


Assembly Language Machine Language
ADD 100101
SUB 010011

Although humans find it easier to work with assembly language, the computer
cannot directly execute the instructions. Because a computer can process its own
instructions as a form of data, it is possible to write a program to translate as-
sembly language instructions into machine code. Such a program is called an
assembler.
Assembly language represents a step in the right direction, but it still forces
programmers to think in terms of individual machine instructions. Eventually,
computer scientists developed high-level programming languages. These lan-
guages are easier to use than assembly languages or machine code because they are closer
to English and other natural languages (see Figure 1.4 on page 12).
A program called a compilertranslates algorithms written in certain high-level languages
(Java, C++, Visual Basic, and Ada, for example) into machine language.If you write an appli-
cation in a high-level language, you can run it on any computer that has the appropriate com-
piler. This portability is possible because most high-level languages are standardized, which
means that an official description of the language exists.


Assembler A program that
translates an assembly
language program into
machine code
Compiler A program that
translates code written in a
high-level language into
machine code
Source code Instructions
written in a high-level program-
ming language
Object code A machine lan-
guage version of a source code

The text of an algorithm written in a high-level language is called source code. To the
compiler, source code is just input data—letters and numbers. It translates the source code
into a machine language form called object code(see Figure 1.5 on page 13).


FOXTROT © 2000 Bill Amend. Reprinted with Permission of UNIVERSAL PRESS SYNDICATE. All Rights Reserved.

Free download pdf