The chapters in this part of the book document the NASM-compatible syntax accepted by
the Yasm “nasm” parser and
preprocessor.
Table of Contents
- 3. The NASM
Language
-
- 3.1. Layout of a NASM
Source Line
- 3.2.
Pseudo-Instructions
-
- 3.2.1.
DB and Friends: Declaring Initialized Data
- 3.2.2.
RESB and Friends: Declaring Uninitialized
Data
- 3.2.3.
INCBIN: Including External Binary Files
- 3.2.4.
EQU: Defining Constants
- 3.2.5.
TIMES: Repeating Instructions or Data
- 3.3. Effective
Addresses
-
- 3.3.1. 64-bit
Displacements
- 3.3.2.
RIP Relative Addressing
- 3.4. Immediate
Operands
- 3.5. Constants
-
- 3.5.1. Numeric
Constants
- 3.5.2. Character
Constants
- 3.5.3. String
Constants
- 3.5.4.
Floating-Point Constants
- 3.6. Expressions
-
- 3.6.1.
|: Bitwise OR Operator
- 3.6.2.
^: Bitwise XOR Operator
- 3.6.3.
&: Bitwise AND Operator
- 3.6.4.
<< and >>: Bit Shift
Operators
- 3.6.5.
+ and -: Addition and
Subtraction Operators
- 3.6.6.
*, /, //,
% and %%: Multiplication and
Division
- 3.6.7. Unary
Operators:
+, -, ~ and SEG
- 3.6.8.
SEG and WRT
- 3.7.
STRICT: Inhibiting Optimization
- 3.8. Critical
Expressions
- 3.9. Local
Labels
- 4. The NASM
Preprocessor
-
- 4.1.
Single-Line Macros
-
- 4.1.1. The
Normal Way:
%define
- 4.1.2.
Enhancing %define:
%xdefine
- 4.1.3. Concatenating Single Line Macro
Tokens:
%+
- 4.1.4.
Undefining macros:
%undef
- 4.1.5.
Preprocessor Variables:
%assign
- 4.2. String Handling in
Macros
-
- 4.2.1. String
Length:
%strlen
- 4.2.2.
Sub-strings:
%substr
- 4.3. Multi-Line
Macros
-
- 4.3.1. Overloading Multi-Line
Macros
- 4.3.2.
Macro-Local Labels
- 4.3.3.
Greedy Macro Parameters
- 4.3.4.
Default Macro Parameters
- 4.3.5.
%0:
Macro Parameter Counter
- 4.3.6.
%rotate: Rotating Macro Parameters
- 4.3.7.
Concatenating Macro Parameters
- 4.3.8.
Condition Codes as Macro Parameters
- 4.3.9.
Disabling Listing Expansion
- 4.4. Conditional
Assembly
-
- 4.4.1.
%ifdef: Testing Single-Line Macro Existence
- 4.4.2.
%ifmacro: Testing Multi-Line Macro Existence
- 4.4.3.
%ifctx: Testing the Context Stack
- 4.4.4.
%if: Testing Arbitrary Numeric Expressions
- 4.4.5.
%ifidn and %ifidni: Testing
Exact Text Identity
- 4.4.6.
%ifid, %ifnum, %ifstr: Testing Token Types
- 4.4.7.
%error: Reporting User-Defined Errors
- 4.5. Preprocessor
Loops
- 4.6. Including Other
Files
- 4.7. The Context
Stack
-
- 4.7.1.
%push and %pop: Creating and Removing
Contexts
- 4.7.2. Context-Local
Labels
- 4.7.3. Context-Local
Single-Line Macros
- 4.7.4.
%repl: Renaming a Context
- 4.7.5. Example Use of the Context
Stack: Block IFs
- 4.8. Standard Macros
-
- 4.8.1.
__YASM_MAJOR__, etc: Yasm Version
- 4.8.2.
__FILE__ and __LINE__: File
Name and Line Number
- 4.8.3.
__YASM_OBJFMT__ and __OUTPUT_FORMAT__: Output Object Format Keyword
- 4.8.4.
STRUC and ENDSTRUC: Declaring
Structure Data Types
- 4.8.5.
ISTRUC, AT and IEND: Declaring Instances of Structures
- 4.8.6.
ALIGN and ALIGNB: Data
Alignment
- 5. NASM Assembler
Directives
-
- 5.1.
Specifying Target Processor Mode
-
- 5.1.1.
BITS
- 5.1.2.
USE16, USE32, and USE64
- 5.2.
DEFAULT: Change the assembler defaults
- 5.3. Changing and
Defining Sections
-
- 5.3.1.
SECTION and SEGMENT
- 5.3.2.
Standardized Section Names
- 5.3.3. The
__SECT__ Macro
- 5.4.
ABSOLUTE: Defining Absolute Labels
- 5.5.
EXTERN: Importing Symbols
- 5.6.
GLOBAL: Exporting Symbols
- 5.7.
COMMON: Defining Common Data Areas
- 5.8.
CPU: Defining CPU Dependencies