Assembly language programming is referred to low-level programming because each assembly language instruction performs a much lower-level task compared to an instruction in a high-level language. Assembly language instructions are processor specification dependents. For example, a program written in the Intel assembly language cannot be executed on the PowerPC processor.
Here are some IA-32 assembly language examples:
inc result
mov class_size, 45
and mask1, 128
add marks, 10
The first instruction increments the variable result. This assembly language instruction is equivalent to
result++;
in C. The second instruction initializes
class_size
to 45. The equivalent statement in C is
class_size = 45;
The third instruction performs the bitwise and operation on
mask1
and can be expressed in C as
mask1 = mask1 & 128;
The last instruction updates marks by adding 10. In C, this is equivalent to
marks = marks + 10;
We can translate the assembly language instructions to the equivalent machine language instructions. Machine language instructions are written in the hexadecimal number system. Here are some IA-32 machine language examples:
Assembly
|
Operation
|
Machine language (in hex)
|
nop
| No operation | 90 |
inc result
| Increment | FF060A00 |
mov class_size, 45
| Copy | C7060C002D00 |
and mask, 128
| Logical and | 80260E0080 |
add marks, 10
| Integer addition | 83060F000A |
References
- Guide to RISC Processors for Programmers and Engineers by Sivarama P. Dandamudi, Springer (2005), ISBN 0-387-21017-2.