Assembly Language
- In Turkish
- Assembly Dili
In short
Assembly language is a low-level language whose instructions map almost one-to-one onto a processor's machine code, written as short mnemonics like mov and add.
What is assembly language?
Assembly language is the lowest-level human-readable way to program a computer. Each line usually corresponds to a single machine instruction, written as a short mnemonic such as mov (copy a value), add or jmp (jump to another instruction), followed by operands like registers or memory addresses. A program called an assembler translates this text into the binary machine code the processor actually runs.
There is no single assembly language: each processor architecture, such as x86-64, ARM64 or RISC-V, has its own instruction set and therefore its own assembly language, and even one architecture can have several syntaxes, like the Intel and AT&T styles for x86. Assembly works directly with registers, the tiny, extremely fast storage slots inside the CPU, and with memory addresses, and it has no variables, types or loops in the high-level sense. Loops and conditions are built from comparisons and jumps.
Today, most developers never write assembly by hand, because compilers produce excellent machine code. It is still used for bootloaders and the lowest layers of operating systems, embedded microcontrollers with tight limits, performance-critical routines that use special instructions like SIMD (one instruction working on several values at once), and security work such as reverse engineering. Reading a compiler's assembly output is also a common way to understand what code really does on the hardware.
Assembly language is often confused with machine code. Machine code is the raw binary that the CPU executes, while assembly is a text representation of those same instructions that people can read and write. It is also different from WebAssembly, which, despite the name, is a portable bytecode format for virtual machines in browsers and other runtimes rather than the assembly language of any physical processor.
Key takeaways
- Each assembly instruction usually maps to one machine instruction.
- Every CPU architecture, such as x86-64, ARM64 or RISC-V, has its own assembly language.
- An assembler converts assembly text into binary machine code.
- It is used for bootloaders, embedded systems, performance hot spots and reverse engineering.
- WebAssembly is a portable bytecode format, not traditional assembly language.
Example
; Print "Hello" using Linux system calls
section .data
msg db "Hello", 10 ; the text plus a newline (byte 10)
section .text
global _start
_start:
mov rax, 1 ; system call 1 = write
mov rdi, 1 ; file descriptor 1 = standard output
mov rsi, msg ; address of the text
mov rdx, 6 ; number of bytes to write
syscall
mov rax, 60 ; system call 60 = exit
xor rdi, rdi ; exit code 0
syscallReaders ask
Is assembly language still used?
Yes, but mostly in small, specialized pieces of code. Bootloaders, operating system kernels, embedded firmware, cryptography and media libraries still contain hand-written assembly where precise control or maximum speed matters.
What is the difference between assembly language and machine code?
Machine code is the binary instructions a processor executes. Assembly language is a readable text version of those instructions, which an assembler translates into machine code.
Is assembly faster than C?
Hand-written assembly can be faster for small, carefully tuned routines, but modern optimizing compilers usually generate code as good as or better than most people write by hand. Assembly is also tied to one CPU architecture, while C can be recompiled for many.
See also
- CompilerProgramming Fundamentals, p. 11A compiler is a program that translates source code written in a programming language into a lower-level form, such as machine code, that a computer can run.
- CProgramming Languages, p. 3C is a compiled, low-level programming language that gives direct control over memory and is used to build operating systems, drivers, and embedded software.
- BootloaderOperating Systems, p. 1A bootloader is a small program that runs after the computer's firmware starts, loads the operating system kernel into memory, and hands control over to it.
- System CallOperating Systems, p. 31A system call is a request from a program to the operating system kernel to perform a privileged action, such as reading a file or starting a process.
- WebAssemblyWeb Development, p. 59WebAssembly is a compact binary code format that runs in web browsers at near-native speed, letting languages like C++, Rust, and Go power fast web code.
- KernelOperating Systems, p. 17A kernel is the core part of an operating system that manages the CPU, memory, and hardware devices and controls how programs get access to those resources.
Spotted a mistake or something missing on this page?Suggest an edit