Resources | Subject Notes | Computer Science
This section focuses on understanding assembly language, its characteristics, and the role of an assembler.
Assembly language is a low-level programming language. This means it is very close to the machine's instruction set. It uses mnemonic codes to represent machine instructions.
Unlike high-level languages like Python or Java, assembly language is not easily readable or portable across different computer architectures.
Assembly language uses mnemonics – short, easy-to-remember abbreviations – to represent machine instructions. For example, instead of a binary code representing "add two numbers," assembly might use a mnemonic like ADD
.
Here's a simple example:
ADD R1, R2 ; Add the contents of register R2 to register R1 and store the result in R1
In this example, ADD
is the mnemonic, and R1
and R2
represent registers within the processor.
Because assembly language uses mnemonics, a special program called an assembler is required to translate the assembly code into machine code. This process is called assembly or translation.
The assembler reads the assembly code, interprets the mnemonics, and converts them into the binary instructions that the computer's processor can directly execute.
Assembly Code | Mnemonic | Meaning | Machine Code (Example) |
---|---|---|---|
MOV R1, #10 |
MOV |
Move the immediate value 10 into register R1. | 10101010 (This is a simplified example; actual machine code varies) |
ADD R3, R1 |
ADD |
Add the contents of register R1 to register R3 and store the result in R3. | 00000011 00000001 00000010 (Simplified example) |
JMP label |
JMP |
Jump to the instruction labeled "label". | 10110000 00000001 (Simplified example) |
Figure: Suggested diagram: A diagram showing the flow of assembly language through an assembler, from source code to machine code.
Assembly language is typically used in situations where: