You are previewing Art of Assembly Language, 1st Edition.
O'Reilly logo
Art of Assembly Language, 1st Edition

Book Description

Presents assembly language from the high-level programmer's point of view, so you can start writing meaningful programs within days. The High Level Assembler (HLA) that accompanies the book is the first assembler that allows you to write portable assembly language programs that run under either Linux or Windows with nothing more than a recompile. The CD-ROM includes the HLA and the HLA Standard Library, all the source code from the book, and over 50,000 lines of additional sample code, all well-documented and tested. The code compiles and runs as-is under Windows and Linux.

Table of Contents

  1. Copyright
  2. ACKNOWLEDGMENTS
  3. HELLO, WORLD OF ASSEMBLY LANGUAGE
    1. 1.1 Chapter Overview
    2. 1.2 The Anatomy of an HLA Program
    3. 1.3 Running Your First HLA Program
    4. 1.4 Some Basic HLA Data Declarations
    5. 1.5 Boolean Values
    6. 1.6 Character Values
    7. 1.7 An Introduction to the Intel 80×86 CPU Family
    8. 1.8 Some Basic Machine Instructions
    9. 1.9 Some Basic HLA Control Structures
    10. 1.10 Introduction to the HLA Standard Library
    11. 1.11 Additional Details About TRY..ENDTRY
    12. 1.12 High Level Assembly Language vs. Low Level Assembly
    13. 1.13 For More Information
  4. DATA REPRESENTATION
    1. 2.1 Chapter Overview
    2. 2.2 Numbering Systems
    3. 2.3 The Hexadecimal Numbering System
    4. 2.4 Data Organization
    5. 2.5 Arithmetic Operations on Binary and Hexadecimal Numbers
    6. 2.6 A Note About Numbers vs. Representation
    7. 2.7 Logical Operations on Bits
    8. 2.8 Logical Operations on Binary Numbers and Bit Strings
    9. 2.9 Signed and Unsigned Numbers
    10. 2.10 Sign Extension, Zero Extension, Contraction, and Saturation
    11. 2.11 Shifts and Rotates
    12. 2.12 Bit Fields and Packed Data
    13. 2.13 An Introduction to Floating Point Arithmetic
    14. 2.14 Binary Coded Decimal (BCD) Representation
    15. 2.15 Characters
    16. 2.16 The Unicode Character Set
    17. 2.17 For More Information
  5. MEMORY ACCESS AND ORGANIZATION
    1. 3.1 Chapter Overview
    2. 3.2 The 80×86 Addressing Modes
    3. 3.3 Run-Time Memory Organization
    4. 3.4 How HLA Allocates Memory for Variables
    5. 3.5 HLA Support for Data Alignment
    6. 3.6 Address Expressions
    7. 3.7 Type Coercion
    8. 3.8 Register Type Coercion
    9. 3.9 The Stack Segment and the PUSH and POP Instructions
    10. 3.10 Dynamic Memory Allocation and the Heap Segment
    11. 3.11 The INC and DEC Instructions
    12. 3.12 Obtaining the Address of a Memory Object
    13. 3.13 For More Information
  6. CONSTANTS, VARIABLES, AND DATA TYPES
    1. 4.1 Chapter Overview
    2. 4.2 Some Additional Instructions: INTMUL, BOUND, INTO
    3. 4.3 The TBYTE Data Types
    4. 4.4 HLA Constant and Value Declarations
    5. 4.5 The HLA TYPE Section
    6. 4.6 ENUM and HLA Enumerated Data Types
    7. 4.7 Pointer Data Types
    8. 4.8 The HLA Standard Library CHARS.HHF Module
    9. 4.9 Composite Data Types
    10. 4.10 Character Strings
    11. 4.11 HLA Strings
    12. 4.12 Accessing the Characters Within a String
    13. 4.13 The HLA String Module and Other String-Related Routines
    14. 4.14 In-Memory Conversions
    15. 4.15 Character Sets
    16. 4.16 Character Set Implementation in HLA
    17. 4.17 HLA Character Set Constants and Character Set Expressions
    18. 4.18 The IN Operator in HLA HLL Boolean Expressions
    19. 4.19 Character Set Support in the HLA Standard Library
    20. 4.20 Using Character Sets in Your HLA Programs
    21. 4.21 Arrays
    22. 4.22 Declaring Arrays in Your HLA Programs
    23. 4.23 HLA Array Constants
    24. 4.24 Accessing Elements of a Single Dimension Array
    25. 4.25 Multidimensional Arrays
    26. 4.26 Allocating Storage for Multidimensional Arrays
    27. 4.27 Accessing Multidimensional Array Elements in Assembly Language
    28. 4.28 Large Arrays and MASM (Windows Programmers Only)
    29. 4.29 Records
    30. 4.30 Record Constants
    31. 4.31 Arrays of Records
    32. 4.32 Arrays/Records as Record Fields
    33. 4.33 Controlling Field Offsets Within a Record
    34. 4.34 Aligning Fields Within a Record
    35. 4.35 Pointers to Records
    36. 4.36 Unions
    37. 4.37 Anonymous Unions
    38. 4.38 Variant Types
    39. 4.39 Union Constants
    40. 4.40 Namespaces
    41. 4.41 Dynamic Arrays in Assembly Language
    42. 4.42 HLA Standard Library Array Support
    43. 4.43 For More Information
  7. PROCEDURES AND UNITS
    1. 5.1 Chapter Overview
    2. 5.2 Procedures
    3. 5.3 Saving the State of the Machine
    4. 5.4 Prematurely Returning from a Procedure
    5. 5.5 Local Variables
    6. 5.6 Other Local and Global Symbol Types
    7. 5.7 Parameters
    8. 5.8 Functions and Function Results
    9. 5.9 Recursion
    10. 5.10 Forward Procedures
    11. 5.11 Low Level Procedures and the CALL Instruction
    12. 5.12 Procedures and the Stack
    13. 5.13 Activation Records
    14. 5.14 The Standard Entry Sequence
    15. 5.15 The Standard Exit Sequence
    16. 5.16 Low Level Implementation of Automatic (Local) Variables
    17. 5.17 Low Level Parameter Implementation
    18. 5.18 Procedure Pointers
    19. 5.19 Procedure Parameters
    20. 5.20 Untyped Reference Parameters
    21. 5.21 Managing Large Programs
    22. 5.22 The #INCLUDE Directive
    23. 5.23 Ignoring Duplicate #INCLUDE Operations
    24. 5.24 UNITs and the EXTERNAL Directive
    25. 5.25 Namespace Pollution
    26. 5.26 For More Information
  8. ARITHMETIC
    1. 6.1 Chapter Overview
    2. 6.2 80×86 Integer Arithmetic Instructions
    3. 6.3 Arithmetic Expressions
    4. 6.4 Logical (Boolean) Expressions
    5. 6.5 Machine and Arithmetic Idioms
    6. 6.6 Floating Point Arithmetic
    7. 6.7 Converting Floating Point Expressions to Assembly Language
    8. 6.8 HLA Standard Library Support for Floating Point Arithmetic
    9. 6.9 Putting It All Together
  9. LOW LEVEL CONTROL STRUCTURES
    1. 7.1 Chapter Overview
    2. 7.2 Low Level Control Structures
    3. 7.3 Statement Labels
    4. 7.4 Unconditional Transfer of Control (JMP)
    5. 7.5 The Conditional Jump Instructions
    6. 7.6 "Medium Level" Control Structures: JT and JF
    7. 7.7 Implementing Common Control Structures in Assembly Language
    8. 7.8 Introduction to Decisions
    9. 7.9 State Machines and Indirect Jumps
    10. 7.10 Spaghetti Code
    11. 7.11 Loops
    12. 7.12 Performance Improvements
    13. 7.13 Hybrid Control Structures in HLA
    14. 7.14 For More Information
  10. FILES
    1. 8.1 Chapter Overview
    2. 8.2 File Organization
    3. 8.3 Sequential Files
    4. 8.4 Random Access Files
    5. 8.5 ISAM (Indexed Sequential Access Method) Files
    6. 8.6 Truncating a File
    7. 8.7 For More Information
  11. ADVANCED ARITHMETIC
    1. 9.1 Chapter Overview
    2. 9.2 Multiprecision Operations
    3. 9.3 Operating on Different-Sized Operands
    4. 9.4 Decimal Arithmetic
    5. 9.5 Tables
    6. 9.6 For More Information
  12. MACROS AND THE HLA COMPILE TIME LANGUAGE
    1. 10.1 Chapter Overview
    2. 10.2 Introduction to the Compile Time Language (CTL)
    3. 10.3 The #PRINT and #ERROR Statements
    4. 10.4 Compile Time Constants and Variables
    5. 10.5 Compile Time Expressions and Operators
    6. 10.6 Compile Time Functions
    7. 10.7 Conditional Compilation (Compile Time Decisions)
    8. 10.8 Repetitive Compilation (Compile Time Loops)
    9. 10.9 Macros (Compile Time Procedures)
    10. 10.10 Writing Compile Time "Programs"
    11. 10.11 Using Macros in Different Source Files
    12. 10.12 For More Information
  13. BIT MANIPULATION
    1. 11.1 Chapter Overview
    2. 11.2 What Is Bit Data, Anyway?
    3. 11.3 Instructions That Manipulate Bits
    4. 11.4 The Carry Flag as a Bit Accumulator
    5. 11.5 Packing and Unpacking Bit Strings
    6. 11.6 Coalescing Bit Sets and Distributing Bit Strings
    7. 11.7 Packed Arrays of Bit Strings
    8. 11.8 Searching for a Bit
    9. 11.9 Counting Bits
    10. 11.10 Reversing a Bit String
    11. 11.11 Merging Bit Strings
    12. 11.12 Extracting Bit Strings
    13. 11.13 Searching for a Bit Pattern
    14. 11.14 The HLA Standard Library Bits Module
    15. 11.15 For More Information
  14. THE STRING INSTRUCTIONS
    1. 12.1 Chapter Overview
    2. 12.2 The 80×86 String Instructions
    3. 12.3 Performance of the 80×86 String Instructions
    4. 12.4 For More Information
  15. THE MMX INSTRUCTION SET
    1. 13.1 Chapter Overview
    2. 13.2 Determining Whether a CPU Supports the MMX Instruction Set
    3. 13.3 The MMX Programming Environment
    4. 13.4 The Purpose of the MMX Instruction Set
    5. 13.5 Saturation Arithmetic and Wrap-Around Mode
    6. 13.6 MMX Instruction Operands
    7. 13.7 MMX Technology Instructions
    8. 13.8 The MMX Programming Paradigm
    9. 13.9 For More Information
  16. CLASSES AND OBJECTS
    1. 14.1 Chapter Overview
    2. 14.2 General Principles
    3. 14.3 Classes in HLA
    4. 14.4 Objects
    5. 14.5 Inheritance
    6. 14.6 Overriding
    7. 14.7 Virtual Methods vs. Static Procedures
    8. 14.8 Writing Class Methods and Procedures
    9. 14.9 Object Implementation
    10. 14.10 Constructors and Object Initialization
    11. 14.11 Destructors
    12. 14.12 HLA's "_initialize_" and "_finalize_" Strings
    13. 14.13 Abstract Methods
    14. 14.14 Run-Time Type Information (RTTI)
    15. 14.15 Calling Base Class Methods
    16. 14.16 For More Information
  17. MIXED LANGUAGE PROGRAMMING
    1. 15.1 Chapter Overview
    2. 15.2 Mixing HLA and MASM/Gas Code in the Same Program
    3. 15.3 Programming in Delphi/Kylix and HLA
    4. 15.4 Programming in C/C++ and HLA
    5. 15.5 For More Information
  18. ASCII CHARACTER SET
  19. THE 80×86 INSTRUCTION SET
  20. Index