What Is Assembly Language?
Assembly language is a low-level programming language in which a processor's instructions are written one per line, with short names such as mov and add instead of binary numbers. A program called an assembler translates it into the machine code the CPU runs.
Updated November 16, 2026
This program prints one line. Press Run: it is assembled with NASM, linked into a Linux program and run. It talks to Linux directly through system calls, without the C library.
Hello from assembly!
Each line under _start is one instruction for an x86-64 processor, the kind in most Windows and Linux PCs. There is no print function. The program puts four numbers into the processor's registers and asks the Linux kernel to write the bytes.
Reading the program line by line
section .data starts the part of the program that holds fixed data. msg db "Hello from assembly!", 10 reserves bytes for the text, and db means "define bytes". The 10 at the end is the character code of a newline.
len equ $ - msg is worked out by the assembler, not the processor: $ is the current position, so the difference is the length of the message, 21 bytes.
section .text holds the instructions. global _start makes the label _start visible to the linker, which marks it as the place where the program begins.
mov rax, 1 copies the number 1 into the register rax. A register is a small storage slot inside the processor itself, 64 bits wide on x86-64, and most calculations happen in registers. The next three mov lines fill rdi, rsi and rdx the same way.
syscall hands control to the operating system. Linux looks at rax to see which service is wanted (1 is write) and at rdi, rsi and rdx for its arguments: where to write, the address of the bytes, and how many. The second syscall, with 60 in rax, ends the program with exit code 0.
The words after ; are comments. The assembler ignores them, and in assembly they matter more than in most languages, because the instructions say what happens but not why.
How assembly becomes a program
The processor cannot read the text above. An assembler translates it into machine code, and a linker turns that into a file the operating system can run:
- The assembler (
nasm -f elf64 hello.asm -o hello.o) translates each instruction into its bytes and writes an object file. - The linker (
ld hello.o -o hello) fills in the final memory addresses, such as wheremsgwill be, and writes the executable. - Running
./hellomakes the kernel load those bytes into memory and start the processor at_start.
A disassembler shows what the assembler produced. Here is objdump -d -M intel hello.o, cut to the first three instructions:
0000000000000000 <_start>:
0: b8 01 00 00 00 mov eax,0x1
5: bf 01 00 00 00 mov edi,0x1
a: 48 be 00 00 00 00 00 movabs rsi,0x0
11: 00 00 00
Each line of assembly became one instruction of 2 to 10 bytes. Two details show that the assembler does more than copy: NASM picked a shorter encoding for mov rax, 1, since writing eax also clears the upper half of rax, and the address of msg is still all zeros because only the linker knows it. The machine code page reads these bytes one by one.
This is the difference from a compiler. A compiler starts from a language such as C, where one line can become many instructions, and chooses those instructions itself. In assembly, you choose every instruction.
Registers do the work
Assembly has no declared variables with types, as Python or C have. You decide where each value lives: in a register while the processor works on it, or in memory, where a label such as digit names the address. This program adds two numbers and prints the result:
7
The sum is the number 7, but the screen shows characters, so the program adds 48, the code of the character 0, before writing it. al is the lowest byte of rax, and [digit] with square brackets means "the memory at the address digit". Change the 5 to 15 and the output is A, the character with code 65: printing a two-digit number takes a loop that divides by 10. That is the trade-off of assembly in one example. You control every step, and you have to write every step.
One assembly language per processor family
Assembly is not one language. Each processor family has its own instructions, registers and rules, and code written for one does not run on another. Here is the same operation, "put 1 in the first argument register", in three of them:
x86-64 (NASM): mov rdi, 1
ARM64: mov x0, #1
RISC-V: li a0, 1
- x86-64 runs most Windows and Linux PCs and servers, on Intel and AMD processors. Its two syntaxes put the operands in opposite order: Intel syntax writes
mov rax, 1, and AT&T syntax, the default of the GNU tools, writesmovq $1, %rax. - ARM64, also called AArch64, runs almost every phone, Macs with Apple silicon, and a growing share of cloud servers.
- RISC-V is an open instruction set, common in microcontrollers and teaching.
Older families such as the 8086, the 6502 and MIPS are still taught at universities because they are small. The ideas carry over between all of them: registers, memory addresses, compare and jump.
What assembly language is used for
- Operating systems. The code that starts the processor, handles interrupts and switches between programs is partly written in assembly. The Linux kernel keeps it in a separate folder for each processor family.
- Speed-critical loops. Video decoders such as dav1d and media tools such as FFmpeg use hand-written assembly for the few loops where they spend most of their time.
- Embedded systems. Very small chips, with a few kilobytes of memory, sometimes need code where every byte is chosen.
- Reading what a compiler made.
gcc -Sand sites such as Compiler Explorer show the assembly behind C, C++ or Rust code, which is how people check optimizations. - Security and reverse engineering. A program without its source code can still be disassembled, which is how malware analysts and exploit developers read it.
- Learning how computers work. A segmentation fault, a stack overflow or a pointer makes much more sense after writing the instructions behind them.
Common myths about assembly
- "Assembly is machine code." It is text that maps closely to machine code. Labels, comments,
dbandequexist only for the assembler, and it chooses encodings for you, asmov rax, 1showed. - "Assembly is always faster." Code is only as fast as the instructions chosen, and modern compilers choose very well. Hand-written assembly wins in narrow cases, usually loops that use special instructions, and the people who write it measure first.
- "You need assembly before any other language." You do not. It is a good second or third language: once you know what a variable and a loop are, seeing how the processor carries them out is easier.
Where to go next
Try changing the programs above in the Assembly playground, which runs the same x86-64 NASM toolchain. The Assembly cheat sheet lists the registers, instructions and Linux system calls on one page. To see what the assembler produces in detail, read what machine code is, and to practice registers, memory, system calls, arithmetic and loops step by step, take the free Assembly course.
Frequently Asked Questions
Is assembly language still used today?
Yes, but in small, specific places. Operating system kernels use it for the code that starts the processor and switches between programs, firmware for tiny chips uses it where every byte counts, and video decoders such as dav1d use hand-written assembly for their busiest loops. Many developers who never write it still read it, when debugging a crash, checking what a compiler produced, or analyzing malware.
Is assembly harder than C++?
print, so a single line of C++ can take ten lines of assembly.What is the difference between assembly and an assembler?
mov rax, 1. An assembler is the program that translates that text into machine code, such as NASM, the GNU assembler as, or Microsoft's MASM. People often say "assembler" for the language too, especially in German, Russian and Polish, where it is the usual name.Is C++ an assembly language?
-S flag.How many assembly languages are there?
One for every processor family, plus different syntaxes for some of them. The common ones today are x86-64 for Intel and AMD PCs, ARM64 for phones and Apple silicon Macs, and RISC-V. For x86-64 alone there are two syntaxes, Intel (used by NASM and MASM) and AT&T (the default of the GNU assembler).