NASM – The Netwide Assembler version 2.14rc3 © 1996−2017 The NASM Development Team — All Rights Reserved This document is redistributable under the license given in the file "LICENSE" distributed in the NASM archive. Contents Chapter 1: Introduction . 17 1.1 What Is NASM?. 17 1.1.1 License Conditions . 17 Chapter 2: Running NASM . 19 2.1 NASM Command−Line Syntax . 19 2.1.1 The −o Option: Specifying the Output File Name . 19 2.1.2 The −f Option: Specifying the Output File Format . 20 2.1.3 The −l Option: Generating a Listing File . 20 2.1.4 The −M Option: Generate Makefile Dependencies. 20 2.1.5 The −MG Option: Generate Makefile Dependencies . 20 2.1.6 The −MF Option: Set Makefile Dependency File. 20 2.1.7 The −MD Option: Assemble and Generate Dependencies . 20 2.1.8 The −MT Option: Dependency Target Name . 21 2.1.9 The −MQ Option: Dependency Target Name (Quoted) . 21 2.1.10 The −MP Option: Emit phony targets . 21 2.1.11 The −MW Option: Watcom Make quoting style . 21 2.1.12 The −F Option: Selecting a Debug Information Format . 21 2.1.13 The −g Option: Enabling Debug Information. 21 2.1.14 The −X Option: Selecting an Error Reporting Format . 21 2.1.15 The −Z Option: Send Errors to a File. 22 2.1.16 The −s Option: Send Errors to stdout ..........................22 2.1.17 The −i Option: Include File Search Directories . 22 2.1.18 The −p Option: Pre−Include a File . 22 2.1.19 The −d Option: Pre−Define a Macro . 23 2.1.20 The −u Option: Undefine a Macro . 23 2.1.21 The −E Option: Preprocess Only. 23 2.1.22 The −a Option: Don’t Preprocess At All . 23 2.1.23 The −O Option: Specifying Multipass Optimization . 23 2.1.24 The −t Option: Enable TASM Compatibility Mode . 24 2.1.25 The −w and −W Options: Enable or Disable Assembly Warnings . 24 2.1.26 The −v Option: Display Version Info . 25 2.1.27 The −y Option: Display Available Debug Info Formats. 25 2.1.28 The −−prefix and −−postfix Options. 26 3 2.1.29 The NASMENV Environment Variable . 26 2.2 Quick Start for MASM Users . 26 2.2.1 NASM Is Case−Sensitive. 26 2.2.2 NASM Requires Square Brackets For Memory References. 26 2.2.3 NASM Doesn’t Store Variable Types. 27 2.2.4 NASM Doesn’t ASSUME ...................................27 2.2.5 NASM Doesn’t Support Memory Models . 27 2.2.6 Floating−Point Differences . 27 2.2.7 Other Differences. 27 Chapter 3: The NASM Language . 29 3.1 Layout of a NASM Source Line . 29 3.2 Pseudo−Instructions . 30 3.2.1 DB and Friends: Declaring Initialized Data . 30 3.2.2 RESB and Friends: Declaring Uninitialized Data . 30 3.2.3 INCBIN: Including External Binary Files . 30 3.2.4 EQU: Defining Constants . 31 3.2.5 TIMES: Repeating Instructions or Data. 31 3.3 Effective Addresses . 31 3.4 Constants . 33 3.4.1 Numeric Constants . 33 3.4.2 Character Strings . 33 3.4.3 Character Constants . 34 3.4.4 String Constants . 34 3.4.5 Unicode Strings . 35 3.4.6 Floating−Point Constants. 35 3.4.7 Packed BCD Constants . 36 3.5 Expressions . 36 3.5.1 |: Bitwise OR Operator . 36 3.5.2 ^: Bitwise XOR Operator . 37 3.5.3 &: Bitwise AND Operator . 37 3.5.4 << and >>: Bit Shift Operators . 37 3.5.5 + and −: Addition and Subtraction Operators. 37 3.5.6 *, /, //, % and %%: Multiplication and Division . 37 3.5.7 Unary Operators . 37 3.6 SEG and WRT ..........................................37 3.7 STRICT: Inhibiting Optimization . 38 4 3.8 Critical Expressions . 38 3.9 Local Labels . 39 Chapter 4: The NASM Preprocessor . 41 4.1 Single−Line Macros . 41 4.1.1 The Normal Way: %define ................................41 4.1.2 Resolving %define: %xdefine..............................42 4.1.3 Macro Indirection: %[...].................................43 4.1.4 Concatenating Single Line Macro Tokens: %+........................43 4.1.5 The Macro Name Itself: %? and %?? ............................43 4.1.6 Undefining Single−Line Macros: %undef..........................44 4.1.7 Preprocessor Variables: %assign .............................44 4.1.8 Defining Strings: %defstr .................................45 4.1.9 Defining Tokens: %deftok.................................45 4.2 String Manipulation in Macros. 45 4.2.1 Concatenating Strings: %strcat .............................45 4.2.2 String Length: %strlen ..................................45 4.2.3 Extracting Substrings: %substr ..............................46 4.3 Multi−Line Macros: %macro ...................................46 4.3.1 Overloading Multi−Line Macros. 47 4.3.2 Macro−Local Labels . 47 4.3.3 Greedy Macro Parameters . 48 4.3.4 Macro Parameters Range . 48 4.3.5 Default Macro Parameters . 49 4.3.6 %0: Macro Parameter Counter . 50 4.3.7 %00: Label Preceeding Macro . 50 4.3.8 %rotate: Rotating Macro Parameters . 50 4.3.9 Concatenating Macro Parameters . 51 4.3.10 Condition Codes as Macro Parameters . 52 4.3.11 Disabling Listing Expansion . 52 4.3.12 Undefining Multi−Line Macros: %unmacro ........................53 4.4 Conditional Assembly . 53 4.4.1 %ifdef: Testing Single−Line Macro Existence . 53 4.4.2 %ifmacro: Testing Multi−Line Macro Existence . 54 4.4.3 %ifctx: Testing the Context Stack . 54 4.4.4 %if: Testing Arbitrary Numeric Expressions . 54 4.4.5 %ifidn and %ifidni: Testing Exact Text Identity . 55 5 4.4.6 %ifid, %ifnum, %ifstr: Testing Token Types. 55 4.4.7 %iftoken: Test for a Single Token . 56 4.4.8 %ifempty: Test for Empty Expansion . 56 4.4.9 %ifenv: Test If Environment Variable Exists . 56 4.5 Preprocessor Loops: %rep ...................................56 4.6 Source Files and Dependencies . 57 4.6.1 %include: Including Other Files . 57 4.6.2 %pathsearch: Search the Include Path. 58 4.6.3 %depend: Add Dependent Files . 58 4.6.4 %use: Include Standard Macro Package.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages276 Page
-
File Size-