From Fundamentals to Advanced Techniques
Introduction: Why Assembly Still Matters
Chapter 1: The x64 Landscape
- Why Assembly Still Matters in 2026
- The Journey from x86 to x64: AMD64 and Intel 64
- The Windows x64 Ecosystem: Toolchain Overview
- Development Environment Setup
- Your First x64 Program: Hello World in Assembly
- Exercises
Chapter 2: The x64 Architecture Deep Dive
- The Register File: General-Purpose, Flags, and Special Registers
- Floating-Point and SIMD Registers: XMM, YMM, ZMM
- Instruction Encoding and OpCodes
- Addressing Modes: Immediate, Register, Direct, and Indirect
- Data Types and Memory Layout: Bytes, Words, Dwords, Qwords
- The Condition Code Register and Flags
- Exercises
Chapter 3: The x64 Calling Convention
- Overview of Calling Conventions: Why They Matter
- The Windows x64 Fast Call Convention: Register Parameters
- Stack Alignment and the Red Zone
- Parameter Passing: Integer/Pointer vs. Floating-Point Registers
- Return Values and the RAX Register
- Caller-Saved vs. Callee-Saved Registers
- Variadic Functions and the Vector Register Mask
- Practical Examples: Calling and Being Called
- Exercises
Chapter 4: Stack Frames and Function Prologues/Epilogues
- The Call Stack: Structure and Purpose
- Frame Pointers vs. Frameless Functions
- Building a Stack Frame: The Prologue Pattern
- Allocating and Freeing Local Variables
- Aligning the Stack for SIMD Operations
- Exception Handling Frames (SEH) and the Frame Pointer Chain
- Debugging Stack Frames with Visual Studio
- Exercises
Chapter 5: Memory Management in x64 Assembly
- Virtual Memory and the x64 Address Space (8TB User, 256TB Kernel)
- Heap Allocation via Windows API (HeapAlloc, VirtualAlloc)
- Stack vs. Heap: When to Use Each
- Memory Alignment Requirements for SIMD and Performance
- Cache Lines and Locality: Avoiding False Sharing
- Memory-Mapped Files and Direct Access
- Security: DEP, ASLR, and Stack Canaries
- Exercises
Chapter 6: Working with the Windows API from Assembly
- Introduction to the Windows API and P/Invoke Concepts
- Loading DLLs and Resolving Function Addresses
- Calling Win32 Functions: MessageBox, CreateFile, ReadFile, WriteFile
- Unicode vs. ANSI: String Handling in Assembly
- Error Handling: GetLastError and HRESULT
- Practical Project: A File Copy Utility in Assembly
- Exercises
Chapter 7: SIMD Programming: SSE, AVX, and AVX-512
- SIMD Fundamentals: Why Parallelism at the Instruction Level
- SSE (128-bit): Registers, Instructions, and Data Types
- AVX (256-bit): Extending SIMD Width
- AVX-512 (512-bit): The Cutting Edge and Masking
- Data Alignment and Packing for SIMD Operations
- Practical Examples: Vector Addition, Dot Product, Image Processing
- Interfacing SIMD with the Calling Convention
- Exercises
Chapter 8: PE Internals: The Portable Executable Format
- The PE File Structure: DOS Header, PE Signature, COFF Header
- Section Table: .text, .data, .rdata, .bss, and More
- The Import Table: Resolving External Dependencies
- The Export Table: Sharing Code Across Modules
- Relocations and Patching: Making Code Position-Independent
- Debug Information: PDB Files and Symbol Tables
- Practical Exercise: Inspecting a PE File with Tools
- Exercises
Chapter 9: Exception Handling in Windows
- Exceptions vs. Errors: The Windows Model
- Structured Exception Handling (SEH): The Original Mechanism
- The Exception Registration Record (ERR) Chain
- Try/Except and Try/Finally in Assembly
- Access Violations and Debugging Crashes
- Modern C++ Exceptions: How They Map to SEH Internals
- Writing Robust Code with Proper Exception Handling
- Exercises
Chapter 10: Multithreading and Synchronization
- Threads in Windows: Creation, Lifecycle, and Threading Model
- Creating Threads from Assembly (CreateThread, _beginthreadex)
- Synchronization Primitives: Mutexes, Semaphores, Critical Sections
- Atomic Operations: Interlocked Functions and Lock-Free Programming
- Memory Ordering and the x64 Memory Model
- Thread-Local Storage (TLS)
- Practical Project: A Simple Parallel Counter
- Exercises
Chapter 11: Reverse Engineering Basics
- What is Reverse Engineering? Ethics and Legal Considerations
- Disassembly vs. Decompilation: Tools of the Trade
- Reading Disassembled Code: Patterns and Conventions
- Identifying Functions, Loops, and Data Structures
- Understanding Compiler Optimizations in Disassembly
- Practical Exercise: Reverse Engineering a Simple Program
- Exercises
Chapter 12: Optimization Techniques
- Profiling and Identifying Bottlenecks (VTune, Perf)
- Instruction-Level Parallelism and Out-of-Order Execution
- Branch Prediction and Avoiding Branches
- Loop Unrolling and Software Pipelining
- Register Allocation and Spilling
- SIMD Optimization Patterns
- Microbenchmarks: Measuring Real Performance
- Exercises
Chapter 13: Debugging Assembly Code
- The Debugger’s View: Registers, Memory, and Disassembly Panes
- Setting Breakpoints and Stepping Through Code
- Inspecting the Call Stack and Local Variables
- Data Breakpoints and Hardware Breakpoints
- Debugging Crashes: Access Violations and Stack Overflows
- Using Visual Studio Debugger for Assembly
- Command-Line Debugging with WinDbg
- Exercises
Chapter 14: Secure Coding in Assembly
- Common Attack Vectors: Buffer Overflows, ROP, JIT Spraying
- Stack Canaries and Canary Values
- Safe String Operations and Bounds Checking
- Control Flow Integrity (CFI)
- Secure Memory Management: Preventing Use-After-Free
- Information Disclosure and Side Channels
- Best Practices for Writing Secure Assembly
- Exercises
Chapter 15: Advanced Topics and Future Directions
- Kernel-Mode Programming: Introduction to Windows Drivers
- The Future of x64: Instruction Set Extensions and Trends
- Comparing x64 to ARM64: Cross-Platform Considerations
- Emerging Tools and Techniques in Low-Level Programming
- Resources for Continued Learning
- Exercises
Conclusion: The Assembly Mindset
- What You’ve Learned: The Big Picture
- When to Use Assembly vs. High-Level Languages
- Building a Mental Model of Low-Level Execution
- Resources for Further Study
- The Community: Forums, Conferences, and Open Source Projects
- Final Thoughts
