(Full Contents)

The Published Edition is now Available!

The Art of Assembly Language is now available from No Starch Press (http://www.nostarch.com) The professionally edited edition is better organized and much easier to read than ever before. The published edition contains a CD-ROM with HLA, example code, additional documentation, and lots of other extras. For those who prefer the Art of Assembly in hard copy form, your ship has come in! (note that the unedited version of AoA will remain available on Webster in electronic form for those who prefer to read the text on-line.)

2.2 Installing the HLA Distribution Package

2.2.1 Installation Under Windows
2.2.2 Installation Under Linux
2.2.3 Installing "Art of Assembly" Related Files

2.9 Some Basic HLA Control Structures

2.9.1 Boolean Expressions in HLA Statements
2.9.2 The HLA IF..THEN..ELSEIF..ELSE..ENDIF Statement
2.9.3 The WHILE..ENDWHILE Statement
2.9.4 The FOR..ENDFOR Statement
2.9.5 The REPEAT..UNTIL Statement
2.9.6 The BREAK and BREAKIF Statements
2.9.7 The FOREVER..ENDFOR Statement
2.9.8 The TRY..EXCEPTION..ENDTRY Statement

2.10 Introduction to the HLA Standard Library

2.10.1 Predefined Constants in the STDIO Module
2.10.2 Standard In and Standard Out
2.10.3 The stdout.newln Routine
2.10.4 The stdout.putiX Routines
2.10.5 The stdout.putiXSize Routines
2.10.6 The stdout.put Routine
2.10.7 The stdin.getc Routine.
2.10.8 The stdin.getiX Routines
2.10.9 The stdin.readLn and stdin.flushInput Routines
2.10.10 The stdin.get Macro

2.12 Sample Programs

2.12.1 Powers of Two Table Generation
2.12.2 Checkerboard Program
2.12.3 Fibonacci Number Generation

3.2 Numbering Systems

3.2.1 A Review of the Decimal System
3.2.2 The Binary Numbering System
3.2.3 Binary Formats

3.3 Data Organization

3.3.1 Bits
3.3.2 Nibbles
3.3.3 Bytes
3.3.4 Words
3.3.5 Double Words

4.2 An Introduction to Floating Point Arithmetic

4.2.1 IEEE Floating Point Formats
4.2.2 HLA Support for Floating Point Values

4.4 Characters

4.4.1 The ASCII Character Encoding
4.4.2 HLA Support for ASCII Characters
4.4.3 The ASCII Character Set

4.6 Other Data Representations

4.6.1 Representing Colors on a Video Display
4.6.2 Representing Audio Information
4.6.3 Representing Musical Information
4.6.4 Representing Video Information

Volume Two:

1.2 The Basic System Components

1.2.1 The System Bus
1.2.1.1 The Data Bus
1.2.1.3 The Control Bus
1.2.2 The Memory Subsystem
1.2.3 The I/O Subsystem

1.4 System Timing

1.4.1 The System Clock
1.4.2 Memory Access and the System Clock
1.4.3 Wait States
1.4.4 Cache Memory

2.1 Chapter Overview

2.2.2 80x86 32-bit Memory Addressing Modes
2.2.2.1 The Displacement Only Addressing Mode
2.2.2.2 The Register Indirect Addressing Modes
2.2.2.4 Variations on the Indexed Addressing Mode

2.3 Run-Time Memory Organization

2.3.1 The Code Section
2.3.2 The Static Sections
2.3.4 The Storage Section
2.3.5 The @NOSTORAGE Attribute
2.3.6 The Var Section
2.3.7 Organization of Declaration Sections Within Your Programs

2.7 The Stack Segment and the Push and Pop Instructions

2.7.1 The Basic PUSH Instruction
2.7.2 The Basic POP Instruction
2.7.3 Preserving Registers With the PUSH and POP Instructions
2.7.4 The Stack is a LIFO Data Structure
2.7.5 Other PUSH and POP Instructions
2.7.6 Removing Data From the Stack Without Popping It
2.7.7 Accessing Data You've Pushed on the Stack Without Popping It

2.11 Bonus Section: The HLA Standard Library CONSOLE Module

2.11.1 Clearing the Screen
2.11.2 Positioning the Cursor
2.11.3 Locating the Cursor
2.11.4 Text Attributes
2.11.5 Filling a Rectangular Section of the Screen
2.11.6 Console Direct String Output
2.11.7 Other Console Module Routines

3.6 What Does This Have To Do With Computers, Anyway?

3.6.1 Correspondence Between Electronic Circuits and Boolean Functions
3.6.2 Combinatorial Circuits
3.6.3 Sequential and Clocked Logic

4.8 Parallelism - the Key to Faster Processors

4.8.1 The Prefetch Queue - Using Unused Bus Cycles
4.8.2 Pipelining - Overlapping the Execution of Multiple Instructions
4.8.2.1 A Typical Pipeline
4.8.2.2 Stalls in a Pipeline
4.8.3 Instruction Caches - Providing Multiple Paths to Memory
4.8.4 Hazards
4.8.5 Superscalar Operation- Executing Instructions in Parallel
4.8.6 Out of Order Execution
4.8.7 Register Renaming
4.8.8 Very Long Instruction Word Architecture (VLIW)
4.8.9 Parallel Processing
4.8.10 Multiprocessing

5.3 Basic Instruction Design Goals

5.3.1 Addressing Modes on the Y86
5.3.2 Encoding Y86 Instructions
5.3.3 Hand Encoding Instructions
5.3.4 Using an Assembler to Encode Instructions
5.3.5 Extending the Y86 Instruction Set

5.4 Encoding 80x86 Instructions

5.4.1 Encoding Instruction Operands
5.4.2 Encoding the ADD Instruction: Some Examples
5.4.3 Encoding Immediate Operands
5.4.4 Encoding Eight, Sixteen, and Thirty-Two Bit Operands
5.4.5 Alternate Encodings for Instructions

6.10 Segments and HLA

6.10.1 Renaming Segments Under Windows

7.4 I/O (Input/Output) Mechanisms

7.4.1 Memory Mapped Input/Output
7.4.2 I/O Mapped Input/Output
7.4.3 Direct Memory Access

Volume Three

1.4 HLA Constant and Value Declarations

1.4.1 Constant Types
1.4.2 String and Character Literal Constants
1.4.3 String and Text Constants in the CONST Section
1.4.4 Constant Expressions
1.4.5 Multiple CONST Sections and Their Order in an HLA Program
1.4.6 The HLA VAL Section
1.4.7 Modifying VAL Objects at Arbitrary Points in Your Programs

1.7 Pointer Data Types

1.7.1 Using Pointers in Assembly Language
1.7.2 Declaring Pointers in HLA
1.7.3 Pointer Constants and Pointer Constant Expressions
1.7.4 Pointer Variables and Dynamic Memory Allocation
1.7.5 Common Pointer Problems

3.9 Low-level Implementation of Set Operations

3.9.1 Character Set Functions That Build Sets
3.9.3 Testing Character Sets

4.5 Accessing Elements of a Single Dimension Array

4.5.1 Sorting an Array of Values

4.6 Multidimensional Arrays

4.6.1 Row Major Ordering
4.6.2 Column Major Ordering

6.4 HLA Date Functions

6.4.1 date.IsValid and date.validate
6.4.2 Checking for Leap Years
6.4.3 Obtaining the System Date
6.4.4 Date to String Conversions and Date Output
6.4.5 date.unpack and data.pack
6.4.6 date.Julian, date.fromJulian
6.4.7 date.datePlusDays, date.datePlusMonths, and date.daysBetween
6.4.8 date.dayNumber, date.daysLeft, and date.dayOfWeek

6.5 Times

6.5.1 time.curTime
6.5.2 time.hmsToSecs and time.secstoHMS
6.5.3 Time Input/Output

7.2 File Organization

7.2.1 Files as Lists of Records
7.2.2 Binary vs. Text Files

7.7 File Utility Routines

7.7.1 Copying, Moving, and Renaming Files
7.7.2 Computing the File Size
7.7.3 Deleting Files

8.7 Parameters

8.7.1 Pass by Value
8.7.2 Pass by Reference

8.8 Functions and Function Results

8.8.1 Returning Function Results
8.8.2 Instruction Composition in HLA
8.8.3 The HLA RETURNS Option in Procedures

9.5 UNITs and the EXTERNAL Directive

9.5.1 Behavior of the EXTERNAL Directive

10.2 80x86 Integer Arithmetic Instructions

10.2.1 The MUL and IMUL Instructions
10.2.2 The DIV and IDIV Instructions
10.2.3 The CMP Instruction
10.2.4 The SETcc Instructions
10.2.5 The TEST Instruction

10.3 Arithmetic Expressions

10.3.1 Simple Assignments
10.3.2 Simple Expressions
10.3.3 Complex Expressions
10.3.4 Commutative Operators

10.5 Machine and Arithmetic Idioms

10.5.1 Multiplying without MUL, IMUL, or INTMUL
10.5.2 Division Without DIV or IDIV
10.5.3 Implementing Modulo-N Counters with AND
10.5.4 Careless Use of Machine Idioms

11.2 Floating Point Arithmetic

11.2.1 FPU Registers
11.2.1.1 FPU Data Registers
11.2.1.2 The FPU Control Register
11.2.1.3 The FPU Status Register
11.2.2 FPU Data Types
11.2.3 The FPU Instruction Set
11.2.4 FPU Data Movement Instructions
11.2.4.1 The FLD Instruction
11.2.4.2 The FST and FSTP Instructions
11.2.4.3 The FXCH Instruction
11.2.5 Conversions
11.2.5.1 The FILD Instruction
11.2.5.2 The FIST and FISTP Instructions
11.2.5.3 The FBLD and FBSTP Instructions
11.2.6 Arithmetic Instructions
11.2.6.2 The FSUB, FSUBP, FSUBR, and FSUBRP Instructions
11.2.6.3 The FMUL and FMULP Instructions
11.2.6.4 The FDIV, FDIVP, FDIVR, and FDIVRP Instructions
11.2.6.5 The FSQRT Instruction
11.2.6.6 The FPREM and FPREM1 Instructions
11.2.6.7 The FRNDINT Instruction
11.2.6.8 The FABS Instruction
11.2.6.9 The FCHS Instruction
11.2.7 Comparison Instructions
11.2.7.1 The FCOM, FCOMP, and FCOMPP Instructions
11.2.7.2 The FTST Instruction
11.2.8 Constant Instructions
11.2.9 Transcendental Instructions
11.2.9.1 The F2XM1 Instruction
11.2.9.2 The FSIN, FCOS, and FSINCOS Instructions
11.2.9.3 The FPTAN Instruction
11.2.9.4 The FPATAN Instruction
11.2.9.5 The FYL2X Instruction
11.2.9.6 The FYL2XP1 Instruction
11.2.10 Miscellaneous instructions
11.2.10.1 The FINIT and FNINIT Instructions
11.2.10.2 The FLDCW and FSTCW Instructions
11.2.10.3 The FCLEX and FNCLEX Instructions
11.2.10.4 The FSTSW and FNSTSW Instructions
11.2.11 Integer Operations

11.3 Converting Floating Point Expressions to Assembly Language

11.3.1 Converting Arithmetic Expressions to Postfix Notation
11.3.2 Converting Postfix Notation to Assembly Language
11.3.3 Mixed Integer and Floating Point Arithmetic

11.4 HLA Standard Library Support for Floating Point Arithmetic

11.4.1 The stdin.getf and fileio.getf Functions
11.4.2 Trigonometric Functions in the HLA Math Library
11.4.3 Exponential and Logarithmic Functions in the HLA Math Library

12.2 Tables

12.2.1 Function Computation via Table Look-up
12.2.2 Domain Conditioning
12.2.3 Generating Tables

Volume Four

1.3 TRY..ENDTRY

1.3.1 Nesting TRY..ENDTRY Statements
1.3.2 The UNPROTECTED Clause in a TRY..ENDTRY Statement
1.3.3 The ANYEXCEPTION Clause in a TRY..ENDTRY Statement
1.3.4 Raising User-Defined Exceptions
1.3.5 Reraising Exceptions in a TRY..ENDTRY Statement
1.3.6 A List of the Predefined HLA Exceptions
1.3.7 How to Handle Exceptions in Your Programs
1.3.8 Registers and the TRY..ENDTRY Statement

2.8 Introduction to Decisions

2.8.1 IF..THEN..ELSE Sequences
2.8.2 Translating HLA IF Statements into Pure Assembly Language
2.8.3 Implementing Complex IF Statements Using Complete Boolean Evaluation
2.8.4 Short Circuit Boolean Evaluation
2.8.5 Short Circuit vs. Complete Boolean Evaluation
2.8.6 Efficient Implementation of IF Statements in Assembly Language
2.8.7 SWITCH/CASE Statements

2.11 Loops

2.11.1 While Loops
2.11.2 Repeat..Until Loops
2.11.3 FOREVER..ENDFOR Loops
2.11.4 FOR Loops
2.11.5 The BREAK and CONTINUE Statements
2.11.6 Register Usage and Loops

2.12 Performance Improvements

2.12.1 Moving the Termination Condition to the End of a Loop
2.12.2 Executing the Loop Backwards
2.12.3 Loop Invariant Computations
2.12.4 Unraveling Loops
2.12.5 Induction Variables

3.8 Parameters

3.8.1 Pass by Value
3.8.2 Pass by Reference
3.8.3 Passing Parameters in Registers
3.8.4 Passing Parameters in the Code Stream
3.8.5 Passing Parameters on the Stack
3.8.5.1 Accessing Value Parameters on the Stack
3.8.5.2 Passing Value Parameters on the Stack
3.8.5.3 Accessing Reference Parameters on the Stack
3.8.5.4 Passing Reference Parameters on the Stack
3.8.5.5 Passing Formal Parameters as Actual Parameters
3.8.5.6 HLA Hybrid Parameter Passing Facilities
3.8.5.7 Mixing Register and Stack Based Parameters

3.13 Sample Programs

3.13.1 Generating the Fibonacci Sequence Using an Iterator
3.13.2 Outer Product Computation with Procedural Parameters

4.2 Multiprecision Operations

4.2.2 Multiprecision Subtraction Operations
4.2.3 Extended Precision Comparisons
4.2.4 Extended Precision Multiplication
4.2.5 Extended Precision Division
4.2.6 Extended Precision NEG Operations
4.2.7 Extended Precision AND Operations
4.2.8 Extended Precision OR Operations
4.2.9 Extended Precision XOR Operations
4.2.10 Extended Precision NOT Operations
4.2.11 Extended Precision Shift Operations
4.2.12 Extended Precision Rotate Operations
4.2.13 Extended Precision I/O
4.2.13.2 Extended Precision Unsigned Decimal Output
4.2.13.3 Extended Precision Signed Decimal Output
4.2.13.4 Extended Precision Formatted I/O
4.2.13.5 Extended Precision Input Routines
4.2.13.7 Extended Precision Unsigned Decimal Input
4.2.13.8 Extended Precision Signed Decimal Input

4.4 Decimal Arithmetic

4.4.1 Literal BCD Constants
4.4.2 The 80x86 DAA and DAS Instructions
4.4.3 The 80x86 AAA, AAS, AAM, and AAD Instructions
4.4.4 Packed Decimal Arithmetic Using the FPU

6.2 The 80x86 String Instructions

6.2.1 How the String Instructions Operate
6.2.2 The REP/REPE/REPZ and REPNZ/REPNE Prefixes
6.2.3 The Direction Flag
6.2.4 The MOVS Instruction
6.2.5 The CMPS Instruction
6.2.6 The SCAS Instruction
6.2.7 The STOS Instruction
6.2.8 The LODS Instruction
6.2.9 Building Complex String Functions from LODS and STOS

7.6 Compile-Time Functions

7.6.1 Type Conversion Compile-time Functions
7.6.2 Numeric Compile-Time Functions
7.6.3 Character Classification Compile-Time Functions
7.6.4 Compile-Time String Functions
7.6.5 Compile-Time Pattern Matching Functions
7.6.6 Compile-Time Symbol Information
7.6.7 Compile-Time Expression Classification Functions
7.6.8 Miscellaneous Compile-Time Functions
7.6.9 Predefined Compile-Time Variables
7.6.10 Compile-Time Type Conversions of TEXT Objects

8.2 Macros (Compile-Time Procedures)

8.2.1 Standard Macros
8.2.2 Macro Parameters
8.2.2.1 Standard Macro Parameter Expansion
8.2.2.2 Macros with a Variable Number of Parameters
8.2.2.3 Required Versus Optional Macro Parameters
8.2.2.4 The "#(" and ")#" Macro Parameter Brackets
8.2.2.5 Eager vs. Deferred Macro Parameter Evaluation
8.2.3 Local Symbols in a Macro
8.2.4 Macros as Compile-Time Procedures
8.2.5 Multi-part (Context-Free) Macros

8.3 Writing Compile-Time "Programs"

8.3.1 Constructing Data Tables at Compile Time
8.3.2 Unrolling Loops

9.2 Introduction to DSELs in HLA

9.2.1 Implementing the Standard HLA Control Structures
9.2.1.1 The FOREVER Loop
9.2.1.2 The WHILE Loop
9.2.1.3 The IF Statement
9.2.2 The HLA SWITCH/CASE Statement
9.2.3 A Modified WHILE Loop
9.2.4 A Modified IF..ELSE..ENDIF Statement

10.9 Object Implementation

10.9.1 Virtual Method Tables
10.9.2 Object Representation with Inheritance

10.10 Constructors and Object Initialization

10.10.1 Dynamic Object Allocation Within the Constructor
10.10.2 Constructors and Inheritance

11.3 The MMX Programming Environment

11.3.1 The MMX Registers
11.3.2 The MMX Data Types

11.7 MMX Technology Instructions

11.7.1 MMX Data Transfer Instructions
11.7.2 MMX Conversion Instructions
11.7.3 MMX Packed Arithmetic Instructions
11.7.4 MMX Logic Instructions
11.7.5 MMX Comparison Instructions
11.7.6 MMX Shift Instructions

12.2 Mixing HLA and MASM/Gas Code in the Same Program

12.2.1 In-Line (MASM/Gas) Assembly Code in Your HLA Programs
12.2.2 Linking MASM/Gas-Assembled Modules with HLA Modules

12.3 Programming in Delphi/Kylix and HLA

12.3.1 Linking HLA Modules With Delphi Programs
12.3.2 Register Preservation
12.3.3 Function Results
12.3.4 Calling Conventions
12.3.5 Pass by Value, Reference, CONST, and OUT in Delphi
12.3.6 Scalar Data Type Correspondence Between Delphi and HLA
12.3.7 Passing String Data Between Delphi and HLA Code
12.3.8 Passing Record Data Between HLA and Delphi
12.3.9 Passing Set Data Between Delphi and HLA
12.3.10 Passing Array Data Between HLA and Delphi
12.3.11 Delphi Limitations When Linking with (Non-TASM) Assembly Code
12.3.12 Referencing Delphi Objects from HLA Code

12.4 Programming in C/C++ and HLA

12.4.1 Linking HLA Modules With C/C++ Programs
12.4.2 Register Preservation
12.4.3 Function Results
12.4.4 Calling Conventions
12.4.5 Pass by Value and Reference in C/C++
12.4.6 Scalar Data Type Correspondence Between C/C++ and HLA
12.4.7 Passing String Data Between C/C++ and HLA Code
12.4.8 Passing Record/Structure Data Between HLA and C/C++
12.4.9 Passing Array Data Between HLA and C/C++