Java Reference
In-Depth Information
adds two numbers, 15 and 12. The program to add two numbers in machine language will look similar to the one
shown below. You do not need to understand the sample code written in this section. It is only for the purpose of
discussion and illustration.
0010010010 10010100000100110
0001000100 01010010001001010
The above instructions are to add two numbers. How difficult will it be to write a program in machine language
to perform a complex task? Based on the above code, you may now realize that it is very difficult to write, read, and
understand a program written in a machine language. But aren't computers supposed to make our jobs easier, not
more difficult? We needed to represent the instructions for computers in some notations that were easier to write,
read, and understand, so computer scientists came up with another language called an assembly language. An
assembly language provides different notations to write instructions. It is little easier to write, read, and understand
than its predecessor, machine language. An assembly language uses mnemonics to represent instructions as opposed
to the binary (0s and 1s) used in machine language. A program written in an assembly language to add two numbers
looks similar to the following:
li $t1, 15
add $t0, $t1, 12
If you compare the two programs written in the two different languages to perform the same task, you can
see that assembly language is easier to write, read, and understand than machine code. There is one-to-one
correspondence between an instruction in machine language and assembly language for a given computer
architecture. Recall that a computer understands instructions only in machine language. The instructions that are
written in an assembly language must be translated into machine language before the computer can execute them.
A program that translates the instructions written in an assembly language into machine language is called an
assembler. Figure 1-1 shows the relationship between assembly code, an assembler, and machine code.
Figure 1-1. The relationship between assembly code, assembler, and machine code
Machine language and assembly language are also known as low-level languages. They are called low-level
languages because a programmer must understand the low-level details of the computer to write a program using
those languages. For example, if you were writing programs in machine and assembly languages, you would need
to know what memory location you are writing to or reading from, which register to use to store a specific value, etc.
Soon programmers realized a need for a higher-level programming language that could hide the low-level details
of computers from them. The need gave rise to the development of high-level programming languages like COBOL,
Pascal, FORTRAN, C, C++, Java, C#, etc. The high-level programming languages use English-like words, mathematical
notation, and punctuation to write programs. A program written in a high-level programming language is also called
source code. They are closer to the written languages that humans are familiar with. The instructions to add two
numbers can be written in a high-level programming language, for example. Java looks similar to the following:
int x = 15 + 27;
 
Search WWH ::




Custom Search