An assembly language is a low-level programming language designed for a specific type of processor. It may be produced by compiling source code from a high-level programming language (such as C/C++) but can also be written from scratch. Assembly code can be converted to machine code using an assembler.
Since most compilers convert source code directly to machine code, software developers often create programs without using assembly language. However, in some cases, assembly code can be used to fine-tune a program. For example, a programmer may write a specific process in assembly language to make sure it functions as efficiently as possible.
While assembly languages differ between processor architectures, they often include similar instructions and operators. Below are some examples of instructions supported by x86 processors.
- MOV - move data from one location to another
- ADD - add two values
- SUB - subtract a value from another value
- PUSH - push data onto a stack
- POP - pop data from a stack
- JMP - jump to another location
- INT - interrupt a process
The following assembly language can be used to add the numbers 3 and 4:
mov eax, 3 - loads 3 into the register "eax"
mov ebx, 4 - loads 4 into the register "ebx"
add eax, ebx, ecx - adds "eax" and "ebx" and stores the result (7) in "ecx"
Writing assembly language is a tedious process since each operation must be performed at a very basic level. While it may not be necessary to use assembly code to create a computer program, learning assembly language is often part of a Computer Science curriculum since it provides useful insight into the way processors work.