Java Reference
In-Depth Information
1.8
What unit is used to measure disk size?
1.9
What is the primary difference between memory and a storage device?
1.3 Programming Languages
Computer programs, known as software, are instructions that tell a computer what to do.
Key
Point
Computers do not understand human languages, so programs must be written in a language a
computer can use. There are hundreds of programming languages, and they were developed
to make the programming process easier for people. However, all programs must be converted
into the instructions the computer can execute.
1.3.1 Machine Language
A computer's native language, which differs among different types of computers, is its
machine language— a set of built-in primitive instructions. These instructions are in the form
of binary code, so if you want to give a computer an instruction in its native language, you
have to enter the instruction as binary code. For example, to add two numbers, you might have
to write an instruction in binary code, like this:
machine language
1101101010011010
1.3.2 Assembly Language
Programming in machine language is a tedious process. Moreover, programs written in
machine language are very difficult to read and modify. For this reason, assembly language
was created in the early days of computing as an alternative to machine languages. Assembly
language uses a short descriptive word, known as a mnemonic , to represent each of the
machine-language instructions. For example, the mnemonic add typically means to add num-
bers and sub means to subtract numbers. To add the numbers 2 and 3 and get the result, you
might write an instruction in assembly code like this:
assembly language
add 2, 3, result
Assembly languages were developed to make programming easier. However, because the
computer cannot execute assembly language, another program—called an assembler —is used
to translate assembly-language programs into machine code, as shown in Figure 1.3.
assembler
Assembly Source File
Machine-Code File
...
add 2, 3, result
...
...
1101101010011010
...
Assembler
F IGURE 1.3
An assembler translates assembly-language instructions into machine code.
Writing code in assembly language is easier than in machine language. However, it is
still tedious to write code in assembly language. An instruction in assembly language essen-
tially corresponds to an instruction in machine code. Writing in assembly requires that you
know how the CPU works. Assembly language is referred to as a low-level language , because
assembly language is close in nature to machine language and is machine dependent.
low-level language
 
 
Search WWH ::




Custom Search