Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Daniel Kusswurm

This book is an instructional text that will teach you how to code x86-64 assembly language functions. It also explains how you can exploit the SIMD capabilities of an x86-64 processor using x86-64 assembly language and the AVX, AVX2, and AVX-512 instruction sets. This updated edition’s content and organization are designed to help you quickly understand x86-64 assembly language programming and the unique computational capabilities of x86 processors. The source code is structured to accelerate learning and comprehension of essential x86-64 assembly language programming constructs and data structures. Modern X86 Assembly Language Programming, Third Edition includes source code for both Windows and Linux. The source code elucidates current x86-64 assembly language programming practices, run-time calling conventions, and the latest generation of software development tools. What You Will Learn Understand important details of the x86-64 processor platform, including its core architecture, data types, registers, memory addressing modes, and the basic instruction set Use the x86-64 instruction set to create assembly language functions that are callable from C++ Create assembly language code for both Windows and Linux using modern software development tools including MASM (Windows) and NASM (Linux) Employ x86-64 assembly language to efficiently manipulate common data types and programming constructs including integers, text strings, arrays, matrices, and user-defined structures Explore indispensable elements of x86 SIMD architectures, register sets, and data types. Master x86 SIMD arithmetic and data operations using both integer and floating-point operands Harness the AVX, AVX2, and AVX-512 instruction sets to accelerate the performance of computationally-intense calculations in machine learning, image processing, signal processing, computer graphics, statistics, and matrix arithm

AI Reading Assistant

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

AI guide
【One-Line Pitch】 A hands-on, code-first guide to writing x86-64 assembly functions that are callable from C++, with deep coverage of SIMD programming using AVX, AVX2, and AVX-512. Ideal for software developers, students, and hobbyists who already know modern C++ and want to squeeze performance out of x86 processors. 【Book Arc】 - **Opening (~0%–15%)**: Introduces the x86-64 core architecture—fundamental data types (byte, word, doubleword, quadword, double quadword), register set, memory addressing modes, and the basic instruction set. Establishes the little-endian byte ordering and bit-numbering conventions used throughout the book. - **Early (~15%–33%)**: Moves into core programming constructs—assembly language for-loops, one- and two-dimensional arrays, string manipulation (counting characters, comparing, copying, filling, reversing), and user-defined structures. Each topic is paired with runnable examples to build fluency in translating C++ logic into assembly. - **Middle (~37%–48%)**: Covers calling conventions in depth—stack arguments, non-volatile general-purpose and XMM registers, and calling external functions—for both Windows (MASM) and Linux (NASM). This is the critical bridge for making assembly functions interoperable with C++ code. Then transitions into SIMD concepts: what SIMD is, packed integer and floating-point arithmetic, and data manipulation operations. - **Middle (~48%–60%)**: Dives into AVX/AVX2 programming with packed integers—addition, subtraction, multiplication, bitwise logic, shifts—and applies these to real-world tasks like pixel clipping, RGB-to-grayscale conversion, pixel conversions, and image histograms. - **Late (~60%–85%)**: Extends SIMD work to packed floating-point—least squares, matrix multiplication—and introduces AVX-512 specifics. The progression moves from elementary operations to size promotions and image-processing pipelines, then to benchmarking and optimization steps. - **Ending (~85%–100%)**: Wraps up with a historical overview of x86 SIMD evolution (SSE through AVX) and a recap of fundamental data types. Appendices cover source code repositories, development tools (Visual Studio 2022/MASM on Windows; GNU C++/NASM on Debian/Ubuntu), and references. 【Key Takeaways】 - **x86-64 data types are the foundation** (Opening): The platform supports 8-bit to 128-bit types—byte, word, doubleword, quadword, double quadword—with little-endian byte ordering. Knowing these and their typical uses (e.g., doubleword for integers and single-precision floats) is prerequisite to reading any assembly example. - **Calling conventions are the bridge to C++** (Middle): Both Windows and Linux have specific rules for stack arguments, non-volatile registers (general-purpose and XMM), and external function calls. Mastering these is what makes assembly functions safely callable from C++—the book's central promise. - **SIMD is about packing data, not just speed** (Middle): SIMD programming concepts—packed integer and floating-point arithmetic, data manipulation—are introduced as a distinct way of thinking, not merely an optimization trick. The AVX register set and data types are explained before any performance discussion. - **AVX/AVX2 packed integers power image processing** (Middle–Late): Practical examples like pixel clipping, RGB-to-grayscale, and image histograms show how SIMD arithmetic and shifts translate directly into visual computing tasks. These are the most concrete demonstrations of the instruction sets' value. - **AVX-512 extends the same patterns** (Late): The book treats AVX-512 as a continuation of AVX/AVX2 rather than a separate paradigm—wider registers and more operands, but the same programming model. This makes the learning curve incremental, not steep. - **Assembly is a trade-off, not a default** (Ending): The author is explicit that assembly coding trades performance gains against development effort and maintainability. The book's goal is to give you the judgment to decide when that trade-off is worth it—not to convince you to write everything in assembly. - **Source code is pedagogical, not production-ready** (Ending): The GitHub examples deliberately omit robust error handling, security hardening, and numerical stability checks. They exist to teach concepts, and you're responsible for production concerns if you reuse them. 【Reading Tips】 - **Skim the historical evolution sections** (Ending): The Netburst/Core/Nehalem/Sandy Bridge recap is interesting context but not needed to write code. Skip ahead if you're here for practical skills. - **Deep-read the calling convention chapters** (Middle ~37%–48%): This is the hardest and most important material. If you only master one section, make it this one—it determines whether your assembly functions actually work when called from C++. - **Use the image-processing examples as your testbed** (Middle–Late): The pixel clipping, grayscale conversion, and histogram examples are self-contained and visually verifiable. Reimplement them from scratch to confirm you understand the SIMD patterns before moving to floating-point matrices. - **Pick one toolchain and stick to it** (Throughout): The book provides both MASM/Visual Studio and NASM/GNU examples. Choose your platform, follow its examples consistently, and only cross-reference the other when you need to understand differences. - **Expect to read code, not just prose** (All): The book's value is in the runnable examples. Plan to type or download the source from GitHub and step through it with a debugger to see registers and memory change in real time. 【Coverage Limits】 This guide is synthesized from the book's table of contents, introduction, and early architecture chapters; it does not cover the detailed instruction-by-instruction content of the AVX-512 chapters, the benchmarking methodology, or the specific code listings. Excerpts do not include the full text of the SIMD programming chapters, so those sections are summarized from their table-of-contents structure rather than their detailed content.
Excerpt 1
a operations using both integer and floating-point operands Harness the AVX, AVX2, and AVX-512 instruction sets to accelerate the performance of computationa...
View in text
Page 3
23 Table of Contents
View in text
Page 4
130 ■ Table of ConTenTs
View in text
Page 5
237 ■ Table of ConTenTs
View in text
Page 6
338 ■ Table of ConTenTs
View in text
Page 3
521 Image Thresholding 521 Image Statistics 530 Image Histogram 543 Summary 547 ■Chapter 14: AVX-512 Programming – Packed Floating-Point – Part 1 549 Floatin...
View in text
Page 13
professional colleagues for their support and encouragement. Finally, I would like to recognize parental nodes Armin (RIP) and Mary along with sibling nodes...
View in text
Page 20
ndamental data types that are intrinsic to the x86 platform. A programmer can employ these fundamental data types to perform assorted arithmetic and data man...
View in text
Tags
AI categories
Programmingx86 assemblySIMD
ISBN: 1484296028
Publisher: Apress
Publish Year: 2023
Language: English
File Format: PDF
File Size: 16.6 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…