Assembly Language
Assembly language is a low-level programming language, and is a human-readable version of machine code.
There are many different assembly languages, because each processor architecture has its own particular assembly language. Every processor has its’ own unique instruction set, and there are also different syntaxes (AT&T vs. Intel) and even conventions that depend on the assembler being used.
Combined with the fact that assembly is very different from higher-level programming languages, these factors make the idea of learning assembly seem like a daunting task.
However, the popular assembly languages used for common system architectures like x86, x64, and even ARM processors, have a great deal more in common than differences between them.
As a result, knowledge of one assembly language will greatly strengthen the ability to learn another. You will find that by learning one version of assembly, you can learn another with relatively minimal difficulty.
The best assembly language to learn is arguably one that you can use immediately. Most people are working on an x86-64 processor, so that’s what we focus on here.
The course and tutorials here attempt to be as language-agnostic as possible, while remaining practical for learning x86-64 assembly.
The goal is to present the most useful information possible to the community of assembly language learners.
This page serves as the main hub for tutorials and a complete course on assembly language. Links to each page are found in the next section.
Assembly Language Course
As the course on assembly language is developed, we will place links to each article below.
Introduction to Assembly Language – What is assembly and where is it used? This lesson introduces fundamental topics related to assembly, including instructions, mnemonic codes, memory, the stack, the heap, and registers.
Computer Memory for Assembly – An overview of computer memory, covering the topics most important for learning assembly.
Binary for Assembly – An introduction to the binary number system and how it relates to Assembly language.
Hexadecimal for Assembly – An introduction to hexadecimal numbers and how they are used in Assembly language.
Assembly Language Registers – A detailed look at registers in x86-64 Assembly. This article contains a high-level overview of the most common registers, and also takes a look at the evolution of registers (and sub-registers) as processors developed from 8 to 64 bits, culminating in x64 architecture.
Understanding the Stack in Assembly – A deep-dive into the stack and how it relates to x86-64 assembly.
Assembly Instructions – An overview of the most common instructions used in x86-64 assembly.
— NOP: The simplest instruction. It doesn’t do anything.
— MOV: The mov (move) instruction allows data to be moved from one location to another.
— XCHG: Exchanges two values.
— PUSH and POP: Used to place items onto, or remove items from, the stack.
— ADD: Adds two operands and stores the value in one (the destination operand).
— SUB: Subtracts one value from another.
— XOR: Performs the bitwise exclusive or (xor) operation.
Two’s Complement: Used to provide support for negative numbers. It allows signed integers to be represented using binary numbers.
Procedures – Procedures are reusable named blocks of code that are used to make the code cleaner, more readable, and more efficient. They are similar to but simpler than functions.
Functions – Functions work a bit differently in assembly languages than in high-level languages, and understanding how they work is critical.
System Calls (syscalls) – System calls are used to perform common, complex tasks such as printing to the screen and exiting a program.
— Exit Syscall: Using a syscall to exit an assembly program.
— Write Syscall: Syscall to write output to the console.
“Hello, World!” in Assembly – Writing the classic “Hello, World!” in x86-64 assembly.
Why Learn Assembly?
Most of the time, programmers don’t write directly in assembly.
Instead, assembly commonly serves as an intermediary language between machine code (the binary code that a computer’s central processing unit, or CPU, understands) and high-level programming languages (such as Java, Python, or Rust) that are easier for humans to read and write.
However, there are lots of great reasons to learn assembly, including:
- Assembly teaches us how computers actually work at a deep level.
- Learning assembly can provide considerable insight into high-level programming languages.
- Any program can be disassembled; ‘everything is open source if you can read assembly!‘
- Programs can be optimized for speed in ways that are virtually impossible using higher-level languages or automated tooling.
- Some fields require knowledge of assembly, including: reverse engineering, malware analysis, and embedded programming.
- Ethical hacking and system security skills are also greatly enhanced by knowledge of assembly.
- Since skill with assembly is relatively rare these days, it can help you stand out from others in your field.
Learning Assembly Language
Learning assembly can be daunting. Every computer architecture or microprocessor has its own version, so an aspiring student may wonder where to start.
That’s why we’re putting together this comprehensive, platform-agnostic course on Assembly. While most of the examples will be focused on 64-bit (x64) development for Windows, we will also cover x86 as well and we’ll see where Linux and OS X development diverge from Windows.
Articles on Assembly Language
Assemblers – An assembler is software that translates assembly code into machine code. This article covers how the assembler actually works, and compares assemblers to compilers.
Supplementary Resources for Learning Assembly Language
While this course strives to be as comprehensive as possible in this course, it is invaluable to learn from other sources as well – this can help you to retain information as well as being exposed to the topic from a different perspective.
There are also other websites that have put together amazing resources that can be helpful for things like learning binary to hexadecimal conversions.
x86 and amd64 instruction reference – From Felix Cloutier. An awesome, comprehensive reference for x86 instructions.
flippybitandtheattackofthehexadecimalsfrombase16 – A great game for learning how to convert between binary and hexadecimal. Games are the best way to learn!