Book description
Assembly is a low-level programming language that's one step above a computer's native machine language. Although assembly language is commonly used for writing device drivers, emulators, and video games, many programmers find its somewhat unfriendly syntax intimidating to learn and use.
Since 1996, Randall Hyde's The Art of Assembly Language has provided a comprehensive, plain-English, and patient introduction to 32-bit x86 assembly for non-assembly programmers. Hyde's primary teaching tool, High Level Assembler (or HLA), incorporates many of the features found in high-level languages (like C, C++, and Java) to help you quickly grasp basic assembly concepts. HLA lets you write true low-level code while enjoying the benefits of high-level language programming.
As you read The Art of Assembly Language, you'll learn the low-level theory fundamental to computer science and turn that understanding into real, functional code.
You'll learn how to:
- Edit, compile, and run an HLA program
- Declare and use constants, scalar variables, pointers, arrays, structures, unions, and namespaces
- Translate arithmetic expressions (integer and floating point)
- Convert high-level control structures
This much anticipated second edition of The Art of Assembly Language has been updated to reflect recent changes to HLA and to support Linux, Mac OS X, and FreeBSD. Whether you're new to programming or you have experience with high-level languages, The Art of Assembly Language, 2nd Edition is your essential guide to learning this complex, low-level language.
Publisher resources
Table of contents
-
PRAISE FOR THE SECOND EDITION OF THE ART OF ASSEMBLY LANGUAGE
- The Art of Assembly Language
- ACKNOWLEDGMENTS
-
1. HELLO, WORLD OF ASSEMBLY LANGUAGE
- 1.1 The Anatomy of an HLA Program
- 1.2 Running Your First HLA Program
- 1.3 Some Basic HLA Data Declarations
- 1.4 Boolean Values
- 1.5 Character Values
- 1.6 An Introduction to the Intel 80x86 CPU Family
- 1.7 The Memory Subsystem
- 1.8 Some Basic Machine Instructions
-
1.9 Some Basic HLA Control Structures
- 1.9.1 Boolean Expressions in HLA Statements
- 1.9.2 The HLA if..then..elseif..else..endif Statement
- 1.9.3 Conjunction, Disjunction, and Negation in Boolean Expressions
- 1.9.4 The while..endwhile Statement
- 1.9.5 The for..endfor Statement
- 1.9.6 The repeat..until Statement
- 1.9.7 The break and breakif Statements
- 1.9.8 The forever..endfor Statement
- 1.9.9 The try..exception..endtry Statement
-
1.10 Introduction to the HLA Standard Library
- 1.10.1 Predefined Constants in the stdio Module
- 1.10.2 Standard In and Standard Out
- 1.10.3 The stdout.newln Routine
- 1.10.4 The stdout.putiX Routines
- 1.10.5 The stdout.putiXSize Routines
- 1.10.6 The stdout.put Routine
- 1.10.7 The stdin.getc Routine
- 1.10.8 The stdin.geti X Routines
- 1.10.9 The stdin.readLn and stdin.flushInput Routines
- 1.10.10 The stdin.get Routine
- 1.11 Additional Details About try..endtry
- 1.12 High-Level Assembly Language vs. Low-Level Assembly Language
- 1.13 For More Information
-
2. DATA REPRESENTATION
- 2.1 Numbering Systems
- 2.2 The Hexadecimal Numbering System
- 2.3 Data Organization
- 2.4 Arithmetic Operations on Binary and Hexadecimal Numbers
- 2.5 A Note About Numbers vs. Representation
- 2.6 Logical Operations on Bits
- 2.7 Logical Operations on Binary Numbers and Bit Strings
- 2.8 Signed and Unsigned Numbers
- 2.9 Sign Extension, Zero Extension, Contraction, and Saturation
- 2.10 Shifts and Rotates
- 2.11 Bit Fields and Packed Data
- 2.12 An Introduction to Floating-Point Arithmetic
- 2.13 Binary-Coded Decimal Representation
- 2.14 Characters
- 2.15 The Unicode Character Set
- 2.16 For More Information
-
3. MEMORY ACCESS AND ORGANIZATION
- 3.1 The 80x86 Addressing Modes
- 3.2 Runtime Memory Organization
- 3.3 How HLA Allocates Memory for Variables
- 3.4 HLA Support for Data Alignment
- 3.5 Address Expressions
- 3.6 Type Coercion
- 3.7 Register Type Coercion
- 3.8 The stack Segment and the push and pop Instructions
- 3.9 The Stack Is a LIFO Data Structure
- 3.10 Accessing Data You've Pushed onto the Stack Without Popping It
- 3.11 Dynamic Memory Allocation and the Heap Segment
- 3.12 The inc and dec Instructions
- 3.13 Obtaining the Address of a Memory Object
- 3.14 For More Information
-
4. CONSTANTS, VARIABLES, AND DATA TYPES
- 4.1 Some Additional Instructions: intmul, bound, into
-
4.2 HLA Constant and Value Declarations
- 4.2.1 Constant Types
- 4.2.2 String and Character Literal Constants
- 4.2.3 String and Text Constants in the const Section
- 4.2.4 Constant Expressions
- 4.2.5 Multiple const Sections and Their Order in an HLA Program
- 4.2.6 The HLA val Section
- 4.2.7 Modifying val Objects at Arbitrary Points in Your Programs
- 4.3 The HLA Type Section
- 4.4 enum and HLA Enumerated Data Types
- 4.5 Pointer Data Types
- 4.6 Composite Data Types
- 4.7 Character Strings
- 4.8 HLA Strings
- 4.9 Accessing the Characters Within a String
- 4.10 The HLA String Module and Other String-Related Routines
- 4.11 In-Memory Conversions
- 4.12 Character Sets
- 4.13 Character Set Implementation in HLA
- 4.14 HLA Character Set Constants and Character Set Expressions
- 4.15 Character Set Support in the HLA Standard Library
- 4.16 Using Character Sets in Your HLA Programs
- 4.17 Arrays
- 4.18 Declaring Arrays in Your HLA Programs
- 4.19 HLA Array Constants
- 4.20 Accessing Elements of a Single-Dimensional Array
- 4.21 Sorting an Array of Values
- 4.22 Multidimensional Arrays
- 4.23 Allocating Storage for Multidimensional Arrays
- 4.24 Accessing Multidimensional Array Elements in Assembly Language
- 4.25 Records
- 4.26 Record Constants
- 4.27 Arrays of Records
- 4.28 Arrays/Records as Record Fields
- 4.29 Aligning Fields Within a Record
- 4.30 Pointers to Records
- 4.31 Unions
- 4.32 Anonymous Unions
- 4.33 Variant Types
- 4.34 Namespaces
- 4.35 Dynamic Arrays in Assembly Language
- 4.36 For More Information
-
5. PROCEDURES AND UNITS
- 5.1 Procedures
- 5.2 Saving the State of the Machine
- 5.3 Prematurely Returning from a Procedure
- 5.4 Local Variables
- 5.5 Other Local and Global Symbol Types
- 5.6 Parameters
- 5.7 Functions and Function Results
- 5.8 Recursion
- 5.9 Forward Procedures
- 5.10 HLA v2.0 Procedure Declarations
- 5.11 Low-Level Procedures and the call Instruction
- 5.12 Procedures and the Stack
- 5.13 Activation Records
- 5.14 The Standard Entry Sequence
- 5.15 The Standard Exit Sequence
- 5.16 Low-Level Implementation of Automatic (Local) Variables
-
5.17 Low-Level Parameter Implementation
- 5.17.1 Passing Parameters in Registers
- 5.17.2 Passing Parameters in the Code Stream
-
5.17.3 Passing Parameters on the Stack
- 5.17.3.1 Accessing Value Parameters on the Stack
- 5.17.3.2 Passing Value Parameters on the Stack
- 5.17.3.3 Accessing Reference Parameters on the Stack
- 5.17.3.4 Passing Reference Parameters on the Stack
- 5.17.3.5 Passing Formal Parameters as Actual Parameters
- 5.17.3.6 HLA Hybrid Parameter-Passing Facilities
- 5.17.3.7 Mixing Register and Stack-Based Parameters
- 5.18 Procedure Pointers
- 5.19 Procedural Parameters
- 5.20 Untyped Reference Parameters
- 5.21 Managing Large Programs
- 5.22 The #include Directive
- 5.23 Ignoring Duplicate #include Operations
- 5.24 Units and the external Directive
- 5.25 Namespace Pollution
- 5.26 For More Information
-
6. ARITHMETIC
- 6.1 80x86 Integer Arithmetic Instructions
- 6.2 Arithmetic Expressions
- 6.3 Logical (Boolean) Expressions
- 6.4 Machine and Arithmetic Idioms
-
6.5 Floating-Point Arithmetic
- 6.5.1 FPU Registers
- 6.5.2 FPU Data Types
- 6.5.3 The FPU Instruction Set
- 6.5.4 FPU Data Movement Instructions
- 6.5.5 Conversions
-
6.5.6 Arithmetic Instructions
- 6.5.6.1 The fadd and faddp Instructions
- 6.5.6.2 The fsub, fsubp, fsubr, and fsurpb Instructions
- 6.5.6.3 The fmul and fmulp Instructions
- 6.5.6.4 The fdiv, fdivp, fdivr, and fdivrp Instructions
- 6.5.6.5 The fsqrt Instruction
- 6.5.6.6 The fprem and fprem1 Instructions
- 6.5.6.7 The frndint Instruction
- 6.5.6.8 The fabs Instruction
- 6.5.6.9 The fchs Instruction
- 6.5.7 Comparison Instructions
- 6.5.8 Constant Instructions
- 6.5.9 Transcendental Instructions
- 6.5.10 Miscellaneous Instructions
- 6.5.11 Integer Operations
- 6.6 Converting Floating-Point Expressions to Assembly Language
- 6.7 HLA Standard Library Support for Floating-Point Arithmetic
- 6.8 For More Information
-
7. LOW-LEVEL CONTROL STRUCTURES
- 7.1 Low-Level Control Structures
- 7.2 Statement Labels
- 7.3 Unconditional Transfer of Control (jmp)
- 7.4 The Conditional Jump Instructions
- 7.5 "Medium-Level" Control Structures: jt and jf
- 7.6 Implementing Common Control Structures in Assembly Language
-
7.7 Introduction to Decisions
- 7.7.1 if..then..else Sequences
-
7.7.2 Translating HLA if Statements into Pure Assembly Language
- if( flag_specification ) then stmts endif;
- if( register ) then stmts endif;
- if( !register ) then stmts endif;
- if( boolean_variable ) then stmts endif;
- if( !boolean_variable ) then stmts endif;
- if( mem_reg relop mem_reg_const ) then stmts endif;
- if( reg/mem in LowConst..HiConst ) then stmts endif;
- if( reg/mem not in LowConst..HiConst ) then stmts endif;
- 7.7.3 Implementing Complex if Statements Using Complete Boolean Evaluation
- 7.7.4 Short-Circuit Boolean Evaluation
- 7.7.5 Short-Circuit vs. Complete Boolean Evaluation
- 7.7.6 Efficient Implementation of if Statements in Assembly Language
- 7.7.7 switch/case Statements
- 7.8 State Machines and Indirect Jumps
- 7.9 Spaghetti Code
- 7.10 Loops
- 7.11 Performance Improvements
- 7.12 Hybrid Control Structures in HLA
- 7.13 For More Information
-
8. ADVANCED ARITHMETIC
-
8.1 Multiprecision Operations
- 8.1.1 HLA Standard Library Support for Extended-Precision Operations
- 8.1.2 Multiprecision Addition Operations
- 8.1.3 Multiprecision Subtraction Operations
- 8.1.4 Extended-Precision Comparisons
- 8.1.5 Extended-Precision Multiplication
- 8.1.6 Extended-Precision Division
- 8.1.7 Extended-Precision neg Operations
- 8.1.8 Extended-Precision and Operations
- 8.1.9 Extended-Precision or Operations
- 8.1.10 Extended-Precision xor Operations
- 8.1.11 Extended-Precision not Operations
- 8.1.12 Extended-Precision Shift Operations
- 8.1.13 Extended-Precision Rotate Operations
-
8.1.14 Extended-Precision I/O
- 8.1.14.1 Extended-Precision Hexadecimal Output
- 8.1.14.2 Extended-Precision Unsigned Decimal Output
- 8.1.14.3 Extended-Precision Signed Decimal Output
- 8.1.14.4 Extended-Precision Formatted Output
- 8.1.14.5 Extended-Precision Input Routines
- 8.1.14.6 Extended-Precision Hexadecimal Input
- 8.1.14.7 Extended-Precision Unsigned Decimal Input
- 8.1.14.8 Extended-Precision Signed Decimal Input
- 8.2 Operating on Different-Size Operands
- 8.3 Decimal Arithmetic
- 8.4 Tables
- 8.5 For More Information
-
8.1 Multiprecision Operations
-
9. MACROS AND THE HLA COMPILE-TIME LANGUAGE
- 9.1 Introduction to the Compile-Time Language (CTL)
- 9.2 The #print and #error Statements
- 9.3 Compile-Time Constants and Variables
- 9.4 Compile-Time Expressions and Operators
-
9.5 Compile-Time Functions
- 9.5.1 Type-Conversion Compile-Time Functions
- 9.5.2 Numeric Compile-Time Functions
- 9.5.3 Character-Classification Compile-Time Functions
- 9.5.4 Compile-Time String Functions
- 9.5.5 Compile-Time Symbol Information
- 9.5.6 Miscellaneous Compile-Time Functions
- 9.5.7 Compile-Time Type Conversions of Text Objects
- 9.6 Conditional Compilation (Compile-Time Decisions)
- 9.7 Repetitive Compilation (Compile-Time Loops)
- 9.8 Macros (Compile-Time Procedures)
- 9.9 Writing Compile-Time "Programs"
- 9.10 Using Macros in Different Source Files
- 9.11 For More Information
-
10. BIT MANIPULATION
- 10.1 What Is Bit Data, Anyway?
- 10.2 Instructions That Manipulate Bits
- 10.3 The Carry Flag as a Bit Accumulator
- 10.4 Packing and Unpacking Bit Strings
- 10.5 Coalescing Bit Sets and Distributing Bit Strings
- 10.6 Packed Arrays of Bit Strings
- 10.7 Searching for a Bit
- 10.8 Counting Bits
- 10.9 Reversing a Bit String
- 10.10 Merging Bit Strings
- 10.11 Extracting Bit Strings
- 10.12 Searching for a Bit Pattern
- 10.13 The HLA Standard Library Bits Module
- 10.14 For More Information
-
11. THE STRING INSTRUCTIONS
-
11.1 The 80x86 String Instructions
- 11.1.1 How the String Instructions Operate
- 11.1.2 The rep/repe/repz and repnz/repne Prefixes
- 11.1.3 The Direction Flag
- 11.1.4 The movs Instruction
- 11.1.5 The cmps Instruction
- 11.1.6 The scas Instruction
- 11.1.7 The stos Instruction
- 11.1.8 The lods Instruction
- 11.1.9 Building Complex String Functions from lods and stos
- 11.2 Performance of the 80x86 String Instructions
- 11.3 For More Information
-
11.1 The 80x86 String Instructions
-
12. CLASSES AND OBJECTS
- 12.1 General Principles
- 12.2 Classes in HLA
- 12.3 Objects
- 12.4 Inheritance
- 12.5 Overriding
- 12.6 Virtual Methods vs. Static Procedures
- 12.7 Writing Class Methods and Procedures
- 12.8 Object Implementation
- 12.9 Constructors and Object Initialization
- 12.10 Destructors
- 12.11 HLA's _initialize_ and _finalize_ Strings
- 12.12 Abstract Methods
- 12.13 Runtime Type Information
- 12.14 Calling Base Class Methods
- 12.15 For More Information
- A. ASCII CHARACTER SET
- COLOPHON
- UPDATES
Product information
- Title: The Art of Assembly Language, 2nd Edition
- Author(s):
- Release date: March 2010
- Publisher(s): No Starch Press
- ISBN: 9781593272074
You might also like
book
Assembly Language Step-by-Step: Programming with Linux®, Third Edition
The eagerly anticipated new edition of the bestselling introduction to x86 assembly language The long-awaited third …
book
Introduction to 80x86 Assembly Language and Computer Architecture, 3rd Edition
A Revised and Updated Edition of the Authoritative Text This revised and updated Third Edition of …
book
Modern Arm Assembly Language Programming: Covers Armv8-A 32-bit, 64-bit, and SIMD
Gain the fundamentals of Armv8-A 32-bit and 64-bit assembly language programming. This book emphasizes Armv8-A assembly …
book
RP2040 Assembly Language Programming: ARM Cortex-M0+ on the Raspberry Pi Pico
Learn to program the Raspberry Pi Pico’s dual ARM Cortex M0+ CPUs in Assembly Language. The …