ASSEMBLY LANGUAGE
To overcome the limitations of machine language, assembly language was introduced in 1952. Assembly language uses alphanumeric code and symbols instead of binary digits to represent instructions and memory addresses. For example, it uses ADD for addition and SUB for subtraction.
NB: Alphanumeric code uses a set of letters and numbers to represent an instruction.
These alphanumeric code and symbols make the program shorter and easier to write than machine language. They also reduce the possibility of errors. Additionally, the programs can be modified easily.
An assembly language is called a second-generation language.
A sample program snippet in an assembly language to add two numbers is shown below:
1. LD Ax, 9
2. LD Bx, 10
3. ADD Ax,Bx
4. LD (100),Ax
5. JMP Bx
6. HLT
Here, Ax and Bx are registers. Registers are nothing but the memory locations inside a microprocessor. Every instruction and data needs to be loaded from main memory to registers before the CPU can process it.
In the above program:
The line number one loads register Ax with the value, 9.
The line number two loads register Bx with the value, 10.
The line number three adds the value of register Bx to the value of register Ax.
The line number four stores the value of register Ax in the main memory location, 100.
The line number five uses JMP to jump to register Bx to transfer the control to register Bx.
The line number six stops the program execution.
As mentioned earlier, a computer cannot understand any language other than machine language. As a result, a translation program is needed to interpret assembly language code into machine language code. This translation program is called an assembler. A code written in any programming language, which requires translation for execution, is known as source code.
Functioning of an Assembler
The assembler takes each program statement in the source code in assembly language and generates a corresponding bit stream or pattern (a series of 0s and 1s of a given length). This set of instructions in a bit stream is the output of the assembler and is called the object code. The object code can then be executed whenever required. The assembler generates a list of errors instead of object code if it finds errors in the source code.
The functioning of an assembler is illustrated in the following figure:
Functioning Of An Assembler |
Advantages of the Assembly Language
Assembly language programs are easier to write and understand than machine language because they use alphanumeric code instead of binary numbers. The programmer can easily remember the opcode and alphanumeric names for the addresses of data and instructions. This saves time and effort in developing and modifying assembly language programs.
Limitations of the Assembly Language
Assembly language also has a few limitations. These are as follows:
- The programs created in assembly language are slower than those created in the machine language. This is because extra time is required to translate assembly language instructions into machine language instructions.
- Programs created in assembly language are dependent on processors because the assembly language vocabulary varies for different processors. Therefore, a program written in assembly language for one processor might not run on another processor.
No comments:
Post a Comment