NASM – The Netwide Assembler version 2.14.03rc2 © 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 . 24 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 . 26 2.1.27 The −y Option: Display Available Debug Info Formats. 26 2.1.28 The −−(g|l)prefix, −−(g|l)postfix Options. 26 3 2.1.29 The −−pragma Option . 26 2.1.30 The −−before Option . 26 2.1.31 The −−limit−X Option . 26 2.1.32 The −−keep−all Option. 27 2.1.33 The −−no−line Option . 27 2.1.34 The NASMENV Environment Variable . 27 2.2 Quick Start for MASM Users . 27 2.2.1 NASM Is Case−Sensitive. 27 2.2.2 NASM Requires Square Brackets For Memory References. 27 2.2.3 NASM Doesn’t Store Variable Types. 28 2.2.4 NASM Doesn’t ASSUME ...................................28 2.2.5 NASM Doesn’t Support Memory Models . 28 2.2.6 Floating−Point Differences . 28 2.2.7 Other Differences. 29 Chapter 3: The NASM Language . 31 3.1 Layout of a NASM Source Line . 31 3.2 Pseudo−Instructions . 32 3.2.1 DB and Friends: Declaring Initialized Data . 32 3.2.2 RESB and Friends: Declaring Uninitialized Data . 32 3.2.3 INCBIN: Including External Binary Files . 32 3.2.4 EQU: Defining Constants . 33 3.2.5 TIMES: Repeating Instructions or Data. 33 3.3 Effective Addresses . 33 3.4 Constants . 35 3.4.1 Numeric Constants . 35 3.4.2 Character Strings . 35 3.4.3 Character Constants . 36 3.4.4 String Constants . 36 3.4.5 Unicode Strings . 37 3.4.6 Floating−Point Constants. 37 3.4.7 Packed BCD Constants . 38 3.5 Expressions . 38 3.5.1 |: Bitwise OR Operator . 38 3.5.2 ^: Bitwise XOR Operator . 39 3.5.3 &: Bitwise AND Operator . 39 3.5.4 << and >>: Bit Shift Operators . 39 4 3.5.5 + and −: Addition and Subtraction Operators. 39 3.5.6 *, /, //, % and %%: Multiplication and Division . 39 3.5.7 Unary Operators . 39 3.6 SEG and WRT ..........................................39 3.7 STRICT: Inhibiting Optimization . 40 3.8 Critical Expressions . 40 3.9 Local Labels . 41 Chapter 4: The NASM Preprocessor . 43 4.1 Single−Line Macros . 43 4.1.1 The Normal Way: %define ................................43 4.1.2 Resolving %define: %xdefine..............................44 4.1.3 Macro Indirection: %[...].................................45 4.1.4 Concatenating Single Line Macro Tokens: %+........................45 4.1.5 The Macro Name Itself: %? and %?? ............................45 4.1.6 Undefining Single−Line Macros: %undef..........................46 4.1.7 Preprocessor Variables: %assign .............................46 4.1.8 Defining Strings: %defstr .................................47 4.1.9 Defining Tokens: %deftok.................................47 4.2 String Manipulation in Macros. 47 4.2.1 Concatenating Strings: %strcat .............................47 4.2.2 String Length: %strlen ..................................47 4.2.3 Extracting Substrings: %substr ..............................48 4.3 Multi−Line Macros: %macro ...................................48 4.3.1 Overloading Multi−Line Macros. 49 4.3.2 Macro−Local Labels . 49 4.3.3 Greedy Macro Parameters . 50 4.3.4 Macro Parameters Range . 50 4.3.5 Default Macro Parameters . 51 4.3.6 %0: Macro Parameter Counter . 52 4.3.7 %00: Label Preceeding Macro . 52 4.3.8 %rotate: Rotating Macro Parameters . 52 4.3.9 Concatenating Macro Parameters . 53 4.3.10 Condition Codes as Macro Parameters . 54 4.3.11 Disabling Listing Expansion . 54 4.3.12 Undefining Multi−Line Macros: %unmacro ........................55 4.4 Conditional Assembly . 55 5 4.4.1 %ifdef: Testing Single−Line Macro Existence . 55 4.4.2 %ifmacro: Testing Multi−Line Macro Existence . 56 4.4.3 %ifctx: Testing the Context Stack . 56 4.4.4 %if: Testing Arbitrary Numeric Expressions . 56 4.4.5 %ifidn and %ifidni: Testing Exact Text Identity . 57 4.4.6 %ifid, %ifnum, %ifstr: Testing Token Types. 57 4.4.7 %iftoken: Test for a Single Token . 58 4.4.8 %ifempty: Test for Empty Expansion . 58 4.4.9.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages284 Page
-
File Size-