NASM - The Netwide Assembler

version 3.02

Table of Contents

Chapters

  1. Chapter 1: Introduction
    1. Section 1.1: What Is NASM?
      1. Section 1.1.1: License
  2. Chapter 2: Running NASM
    1. Section 2.1: NASM Command-Line Syntax
      1. Section 2.1.1: The -o Option: Output File Name
      2. Section 2.1.2: The -f Option: Output File Format
      3. Section 2.1.3: The -l Option: Generating a Listing File
      4. Section 2.1.4: The -L Option: Additional or Modified Listing Info
      5. Section 2.1.5: The -M Option: Generate Makefile Dependencies
      6. Section 2.1.6: The -MG Option: Generate Makefile Dependencies
      7. Section 2.1.7: The -MF Option: Set Makefile Dependency File
      8. Section 2.1.8: The -MD Option: Assemble and Generate Dependencies
      9. Section 2.1.9: The -MT Option: Dependency Target Name
      10. Section 2.1.10: The -MQ Option: Dependency Target Name (Quoted)
      11. Section 2.1.11: The -MP Option: Emit Phony Makefile Targets
      12. Section 2.1.12: The -MW Option: Watcom make quoting style
      13. Section 2.1.13: The -F Option: Debug Information Format
      14. Section 2.1.14: The -g Option: Enabling Debug Information.
      15. Section 2.1.15: The -X Option: Selecting an Error Reporting Format
      16. Section 2.1.16: The -Z Option: Send Errors to a File
      17. Section 2.1.17: The -s Option: Send Errors to stdout
      18. Section 2.1.18: The -i Option: Include File Search Directories
      19. Section 2.1.19: The -p Option: Pre-Include a File
      20. Section 2.1.20: The -d Option: Pre-Define a Macro
      21. Section 2.1.21: The -u Option: Undefine a Macro
      22. Section 2.1.22: The -E Option: Preprocess Only
      23. Section 2.1.23: The -a Option: Suppress Preprocessing
      24. Section 2.1.24: The -O Option: Multipass Optimization
      25. Section 2.1.25: The -t Option: TASM Compatibility Mode
      26. Section 2.1.26: The -w and -W Options: Enable or Disable Assembly Warnings
      27. Section 2.1.27: The -v Option: Display Version Info
      28. Section 2.1.28: The --[gl]prefix and --[gl]postfix Options
      29. Section 2.1.29: The --pragma Option
      30. Section 2.1.30: The --before Option
      31. Section 2.1.31: The --bits Option
      32. Section 2.1.32: The --limit- Options
      33. Section 2.1.33: The --keep-all Option
      34. Section 2.1.34: The --no-line Option
      35. Section 2.1.35: The --reproducible Option
      36. Section 2.1.36: The NASMENV Environment Variable
    2. Section 2.2: Quick Start for MASM Users
      1. Section 2.2.1: NASM Is Case-Sensitive
      2. Section 2.2.2: NASM Requires Square Brackets For Memory References
      3. Section 2.2.3: NASM Doesn't Store Variable Types
      4. Section 2.2.4: NASM Doesn't ASSUME
      5. Section 2.2.5: NASM Doesn't Support Memory Models
      6. Section 2.2.6: Floating-Point Differences
      7. Section 2.2.7: Other Differences
      8. Section 2.2.8: MASM compatibility package
  3. Chapter 3: The NASM Language
    1. Section 3.1: Layout of a NASM Source Line
    2. Section 3.2: Pseudo-Instructions
      1. Section 3.2.1: Dx: Declaring Initialized Data
      2. Section 3.2.2: RESB and Friends: Declaring Uninitialized Data
      3. Section 3.2.3: INCBIN: Including External Binary Files
      4. Section 3.2.4: EQU: Defining Constants
      5. Section 3.2.5: TIMES: Repeating Instructions or Data
    3. Section 3.3: Effective Addresses
    4. Section 3.4: Constants
      1. Section 3.4.1: Numeric Constants
      2. Section 3.4.2: Character Strings
      3. Section 3.4.3: Character Constants
      4. Section 3.4.4: String Constants
      5. Section 3.4.5: Unicode Strings
      6. Section 3.4.6: Floating-Point Constants
      7. Section 3.4.7: Packed BCD Constants
    5. Section 3.5: Expressions
      1. Section 3.5.1: ? ... :: Conditional Operator
      2. Section 3.5.2: : ||: Boolean OR Operator
      3. Section 3.5.3: : ^^: Boolean XOR Operator
      4. Section 3.5.4: : &&: Boolean AND Operator
      5. Section 3.5.5: : Comparison Operators
      6. Section 3.5.6: |: Bitwise OR Operator
      7. Section 3.5.7: ^: Bitwise XOR Operator
      8. Section 3.5.8: &: Bitwise AND Operator
      9. Section 3.5.9: Bit Shift Operators
      10. Section 3.5.10: + and -: Addition and Subtraction Operators
      11. Section 3.5.11: Multiplication, Division and Modulo
      12. Section 3.5.12: Unary Operators
    6. Section 3.6: SEG and WRT
    7. Section 3.7: STRICT: Inhibiting Optimization
    8. Section 3.8: Critical Expressions
    9. Section 3.9: Local Labels
  4. Chapter 4: Syntax Quirks and Summaries
    1. Section 4.1: Summary of the JMP and CALL Syntax
      1. Section 4.1.1: Near Jumps
      2. Section 4.1.2: Infinite Loop Trick
      3. Section 4.1.3: Jumps and Mixed Sizes
      4. Section 4.1.4: Calling Procedures Outside of a Shared Library
      5. Section 4.1.5: FAR Calls and Jumps
      6. Section 4.1.6: 64-bit absolute jump (JMPABS)
      7. Section 4.1.7: Optimizing jump lengths and sizes
    2. Section 4.2: Compact NDS/NDD Operands
    3. Section 4.3: 64-bit moffs
    4. Section 4.4: Split EA Addressing Syntax
    5. Section 4.5: No Syntax for Ternary Logic Instruction
    6. Section 4.6: APX Instruction Syntax
      1. Section 4.6.1: Extended General Purpose Registers (EGPRs)
      2. Section 4.6.2: New Data Destination (NDD)
      3. Section 4.6.3: Suppress Modifying Flags (NF)
      4. Section 4.6.4: Zero Upper (ZU)
      5. Section 4.6.5: Source Condition Code (Scc) and Default Flags Value (DFV)
      6. Section 4.6.6: PUSH and POP Extensions
      7. Section 4.6.7: APX and the NASM optimizer
      8. Section 4.6.8: Force APX Encoding
  5. Chapter 5: The NASM Preprocessor
    1. Section 5.1: Preprocessor Expansions
      1. Section 5.1.1: Continuation Line Collapsing
      2. Section 5.1.2: Comment Removal
      3. Section 5.1.3: %line directives
      4. Section 5.1.4: Conditionals, Loops and Multi-Line Macro Definitions
      5. Section 5.1.5: Directives processing
      6. Section 5.1.6: Inline expansions and other directives
      7. Section 5.1.7: Multi-Line Macro Expansion
      8. Section 5.1.8: Detokenization
    2. Section 5.2: Preprocessor caveats
      1. Section 5.2.1: Case Insensitivity
    3. Section 5.3: Single-Line Macros
      1. Section 5.3.1: The Normal Way: %define
      2. Section 5.3.2: Resolving %define: %xdefine
      3. Section 5.3.3: Macro Indirection: %[...]
      4. Section 5.3.4: Concatenating Single Line Macro Tokens: %+
      5. Section 5.3.5: The Macro Name Itself: %? and %??
      6. Section 5.3.6: The Single-Line Macro Name: %*? and %*??
      7. Section 5.3.7: Undefining Single-Line Macros: %undef
      8. Section 5.3.8: Preprocessor Variables: %assign
      9. Section 5.3.9: Defining Strings: %defstr
      10. Section 5.3.10: Defining Tokens: %deftok
      11. Section 5.3.11: Defining Aliases: %defalias
      12. Section 5.3.12: Conditional Comma Operator: %,
    4. Section 5.4: String Manipulation in Macros
      1. Section 5.4.1: Concatenating Strings: %strcat
      2. Section 5.4.2: String Length: %strlen
      3. Section 5.4.3: Extracting Substrings: %substr
    5. Section 5.5: Preprocessor Functions
      1. Section 5.5.1: %abs() Function
      2. Section 5.5.2: %b2hs() Function
      3. Section 5.5.3: %chr() Function
      4. Section 5.5.4: %cond() Function
      5. Section 5.5.5: %count() Function
      6. Section 5.5.6: %depend() Function
      7. Section 5.5.7: %env() Function
      8. Section 5.5.8: %eval() Function
      9. Section 5.5.9: %find() and %findi() Functions
      10. Section 5.5.10: %hex() Function
      11. Section 5.5.11: %hs2b() Function
      12. Section 5.5.12: %is() Family Functions
      13. Section 5.5.13: %limit() Function
      14. Section 5.5.14: %map() Function
      15. Section 5.5.15: %null() Function
      16. Section 5.5.16: %num() Function
      17. Section 5.5.17: %ord() Function
      18. Section 5.5.18: %pathsearch() Function
      19. Section 5.5.19: %realpath() Function
      20. Section 5.5.20: %sel() Function
      21. Section 5.5.21: %selbits() Function
      22. Section 5.5.22: %str() Function
      23. Section 5.5.23: %strcat() Function
      24. Section 5.5.24: %strlen() Function
      25. Section 5.5.25: %substr() Function
      26. Section 5.5.26: %tok() function
    6. Section 5.6: Multi-Line Macros: %macro
      1. Section 5.6.1: Overloading Multi-Line Macros
      2. Section 5.6.2: Macro-Local Labels
      3. Section 5.6.3: Greedy Macro Parameters
      4. Section 5.6.4: Macro Parameters Range
      5. Section 5.6.5: Default Macro Parameters