Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorLowell, Emrick H.

No description

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# 64-Bit Assembly in Practice: Master Low-Level Programming and Performance Optimization on x86-64 Systems ## 【One-Line Pitch】 A hands-on, practical guide to writing x86-64 assembly for Linux and Windows, covering everything from your first "Hello, World" to bootloaders, shellcode, and OS development—ideal for systems programmers, security researchers, and anyone who wants to truly understand what happens under the hood of modern CPUs. ## 【Book Arc】 - **Opening (~0%–11%)**: Introduces assembly language fundamentals, contrasts 32-bit vs. 64-bit architectures, and explains why low-level programming matters for performance-critical systems, embedded development, and reverse engineering. - **Early (~15%–33%)**: Covers the x86-64 instruction set in depth—data movement, arithmetic, logical operations, FLAGS register handling, memory addressing modes, and the stack. Includes Windows API examples like MessageBox integration. - **Middle (~37%–59%)**: Advances into robust coding practices, low-level file I/O via syscalls and WinAPI, memory mapping (mmap, brk/sbrk), building a simple bump allocator, hardware port access, and a basic BIOS bootloader. Introduces multithreading with clone and CreateThread, plus synchronization primitives. - **Late (~63%–75%)**: Explores security topics—writing shellcode, position-independent code (PIC), encoding/obfuscation techniques, and reverse TCP payloads (educational only)—alongside bootloader and OS development basics. - **Ending (~77%–100%)**: Consolidates toolchain knowledge (NASM, GCC, Clang, FASM, MASM), explains ELF and PE binary formats, and provides a comprehensive reference on instructions, data directives, calling conventions, stack frames, string operations, and control flow patterns. ## 【Key Takeaways】 - **Assembly is symbolic machine code** (Early): Each mnemonic like MOV, ADD, or JMP maps directly to a CPU instruction, giving you precise control over registers, memory, and execution timing—essential for drivers, kernels, and performance-critical code. - **The x86-64 instruction set is your toolbox** (Early): Master data movement (MOV, LEA, PUSH/POP), arithmetic (ADD, IMUL, DIV), bitwise operations (AND, XOR, shifts/rotates), and control flow (JMP, CALL, conditional jumps) to express any algorithm at the hardware level. - **Calling conventions are non-negotiable** (Late): System V ABI (Linux/macOS) passes args in RDI, RSI, RDX, RCX, R8, R9; Microsoft x64 uses RCX, RDX, R8, R9 with 32 bytes of shadow space—getting this wrong breaks interop with C libraries. - **Memory access is explicit and powerful** (Early): Direct vs. indirect addressing, base+index+displacement forms, and the stack discipline (PUSH/POP, RBP/RSP frame setup) give you complete control over data layout and function call mechanics. - **Syscalls are your gateway to the OS** (Middle): Linux uses syscall numbers in RAX with args in RDI/RSI/RDX; Windows uses WinAPI calls—understanding both lets you do file I/O, memory mapping, and process control without libc. - **SIMD unlocks parallel processing** (Late): SSE/AVX vector registers (XMM0–15, YMM0–15) enable single-instruction multi-data operations for image processing, numerical computation, and machine learning workloads. - **Assembly is the foundation of security work** (Middle): Shellcode crafting, position-independent code, and obfuscation techniques are direct applications of assembly knowledge—essential for reverse engineering and exploit analysis. - **String instructions optimize bulk operations** (Ending): REP MOVSB, STOSB, and CMPSB with the direction flag handle memory copying, filling, and comparison with minimal loop overhead. ## 【Reading Tips】 - **Skim the early instruction reference sections** (~15%–33%) if you have prior assembly experience—focus instead on the System V vs. Microsoft x64 calling convention differences and the practical examples. - **Deep-read the middle chapters** (~37%–59%) on file I/O, memory allocation, and the bump allocator—these show real-world patterns you'll reuse in systems programming. - **Treat the shellcode and bootloader chapters** (~59%–75%) as conceptual overviews; the excerpts indicate they're educational, so understand the principles rather than memorizing payloads. - **Use the ending reference material** (~89%–100%) as a lookup guide: data directives (DB, DW, DD, DQ), section organization (.data, .bss, .text), and stack frame patterns are worth bookmarking. - **Set up a Linux environment or WSL** for hands-on practice—the book notes this is the easiest path for beginners, with NASM + ld/GCC as the primary toolchain. ## 【Coverage Limits】 This guide synthesizes the book's structure and key concepts from the sampled excerpts; specific code listings, advanced optimization techniques, and detailed examples for each instruction are not fully reproduced here. ##
Excerpt 1
ey Differences :              17 Why Learn 64-bit Assembly ?              18 Overview of x86-64 Instruction Se t              19 Key Instruction Types :     ...
View in text
Excerpt 2
ry Access and Addressin g              53 Direct vs.
View in text
Excerpt 3
s              81 Example: MessageBox from user32.dll (FASM )              81 Differences from Linux :              82 File Handling: Open, Read, Write, Clos...
View in text
Excerpt 4
    120 Overflow Flag s              120 Signed vs. Unsigned Checks :              120 Manual Overflow Detection :              121 Writing Robust and Safe A...
View in text
Excerpt 5
id Writing to Arbitrary Memor y              156 7. Respect Calling Convention s              156 Performance Optimization Technique s              157 Loop...
View in text
Excerpt 6
s              181 Real Mode vs. Protected Mode vs. Long Mod e              181 Real Mod e              181 Protected Mod e              181 Long Mod e      ...
View in text
Excerpt 7
be aligned to 4-byte boundaries.   ●      8-byte types (e.g., doubl e , lon g ) should be aligned to 8-byte or 16-byte boundaries.   Benefits of proper align...
View in text
Excerpt 8
anced switch cases may use jump tables for faster branching. LOOP Structures: WHILE Loop: mov rcx, 10 while_loop: cmp rcx, 0 je end_while ; loop body dec rcx...
View in text
Tags
AI categories
ProgrammingOSCybersecurity
ISBN: B0FH55BBPQ
Publish Year: 2025
Language: English
File Format: EPUB
File Size: 1.3 MB