Yasm User Manual

Peter Johnson

Шемет Ян

Russian translation 

2009

Аннотация

This document is the user manual for the Yasm assembler. It is intended as both an introduction and a general-purpose reference for all Yasm users.


Содержание

I. Preface
II. Using Yasm
1. Запуск Yasm
1.1. Синтаксис командной строки yasm
1.2. Описание
1.3. Параметры
1.3.1. Основные параметры
1.3.2. Параметры предупреждения
1.3.3. Параметры препроцессора
1.4. Поддерживаемые архитектуры
1.5. Поддерживаемые синтаксические анализаторы (синтаксисы)
1.6. Поддерживаемые форматы объектов
1.7. Поддерживаемые форматы отладки
III. NASM Syntax
2. Язык NASM
2.1. Обзор ассемблерной строки NASM
2.2. Псевдо-инструкции
2.2.1. DB и ее друзья: Объявление инициализированных данных
2.2.2. RESB и ее друзья: Объявление неинициализированных данных
2.2.3. INCBIN: Включение внешних бинарных файлов
2.2.4. EQU: Определение констант
2.2.5. TIMES: Повторение инструкций или данных
2.3. Effective Addresses
2.3.1. 64-bit Displacements
2.3.2. RIP Relative Addressing
2.4. Immediate Operands
2.5. Constants
2.5.1. Numeric Constants
2.5.2. Character Constants
2.5.3. String Constants
2.5.4. Floating-Point Constants
2.6. Expressions
2.6.1. |: Bitwise OR Operator
2.6.2. ^: Bitwise XOR Operator
2.6.3. &: Bitwise AND Operator
2.6.4. << and >>: Bit Shift Operators
2.6.5. + and -: Addition and Subtraction Operators
2.6.6. *, /, //, % and %%: Multiplication and Division
2.6.7. Unary Operators: +, -, ~ and SEG
2.6.8. SEG and WRT
2.7. STRICT: Inhibiting Optimization
2.8. Critical Expressions
2.9. Local Labels
3. The NASM Preprocessor
3.1. Single-Line Macros
3.1.1. The Normal Way: %define
3.1.2. Enhancing %define: %xdefine
3.1.3. Concatenating Single Line Macro Tokens: %+
3.1.4. Undefining macros: %undef
3.1.5. Preprocessor Variables: %assign
3.2. String Handling in Macros
3.2.1. String Length: %strlen
3.2.2. Sub-strings: %substr
3.3. Multi-Line Macros
3.3.1. Overloading Multi-Line Macros
3.3.2. Macro-Local Labels
3.3.3. Greedy Macro Parameters
3.3.4. Default Macro Parameters
3.3.5. %0: Macro Parameter Counter
3.3.6. %rotate: Rotating Macro Parameters
3.3.7. Concatenating Macro Parameters
3.3.8. Condition Codes as Macro Parameters
3.3.9. Disabling Listing Expansion
3.4. Conditional Assembly
3.4.1. %ifdef: Testing Single-Line Macro Existence
3.4.2. %ifmacro: Testing Multi-Line Macro Existence
3.4.3. %ifctx: Testing the Context Stack
3.4.4. %if: Testing Arbitrary Numeric Expressions
3.4.5. %ifidn and %ifidni: Testing Exact Text Identity
3.4.6. %ifid, %ifnum, %ifstr: Testing Token Types
3.4.7. %error: Reporting User-Defined Errors
3.5. Preprocessor Loops
3.6. Including Other Files
3.7. The Context Stack
3.7.1. %push and %pop: Creating and Removing Contexts
3.7.2. Context-Local Labels
3.7.3. Context-Local Single-Line Macros
3.7.4. %repl: Renaming a Context
3.7.5. Example Use of the Context Stack: Block IFs
3.8. Standard Macros
3.8.1. __YASM_MAJOR__, etc: Yasm Version
3.8.2. __FILE__ and __LINE__: File Name and Line Number
3.8.3. __YASM_OBJFMT__ and __OUTPUT_FORMAT__: Output Object Format Keyword
3.8.4. STRUC and ENDSTRUC: Declaring Structure Data Types
3.8.5. ISTRUC, AT and IEND: Declaring Instances of Structures
3.8.6. ALIGN and ALIGNB: Data Alignment
4. NASM Assembler Directives
4.1. Specifying Target Processor Mode
4.1.1. BITS
4.1.2. USE16, USE32, and USE64
4.2. DEFAULT: Change the assembler defaults
4.3. Changing and Defining Sections
4.3.1. SECTION and SEGMENT
4.3.2. Standardized Section Names
4.3.3. The __SECT__ Macro
4.4. ABSOLUTE: Defining Absolute Labels
4.5. EXTERN: Importing Symbols
4.6. GLOBAL: Exporting Symbols
4.7. COMMON: Defining Common Data Areas
4.8. CPU: Defining CPU Dependencies
IV. GAS Syntax
5. TBD
V. Object Formats
6. bin: Flat-Form Binary Output
6.1. ORG: Binary Origin
6.2. bin Extensions to the SECTION Directive
6.3. bin Special Symbols
6.4. Map Files
7. coff: Common Object File Format
8. elf32: Executable and Linkable Format 32-bit Object Files
8.1. Debugging Format Support
8.2. ELF Sections
8.3. ELF Directives
8.3.1. IDENT: Add file identification
8.3.2. SIZE: Set symbol size
8.3.3. TYPE: Set symbol type
8.3.4. WEAK: Create weak symbol
8.4. ELF Extensions to the GLOBAL Directive
8.5. ELF Extensions to the COMMON Directive
8.6. elf32 Special Symbols and WRT
9. elf64: Executable and Linkable Format 64-bit Object Files
9.1. elf64 Special Symbols and WRT
10. macho32: Mach 32-bit Object File Format
11. macho64: Mach 64-bit Object File Format
12. rdf: Relocatable Dynamic Object File Format
13. win32: Microsoft Win32 Object Files
14. win64: PE32+ (Microsoft Win64) Object Files
14.1. win64 Extensions to the SECTION Directive
14.2. win64 Structured Exception Handling
14.2.1. x64 Stack, Register and Function Parameter Conventions
14.2.2. Types of Functions
14.2.3. Frame Function Structure
14.2.4. Stack Frame Details
14.2.5. Yasm Primitives for Unwind Operations
14.2.6. Yasm Macros for Formal Stack Operations
15. xdf: Extended Dynamic Object Format
VI. Debugging Formats
16. cv8: CodeView Debugging Format for VC8
17. dwarf2: DWARF2 Debugging Format
18. stabs: Stabs Debugging Format
VII. Architectures
19. x86 Architecture
19.1. Instructions
19.1.1. NOP Padding
19.2. Execution Modes and Extensions
19.2.1. CPU Options
19.3. Registers
19.4. Segmentation
VIII. Index

Список иллюстраций

14.1. x64 Calling Convention
14.2. x64 Detailed Stack Frame
19.1. x86 General Purpose Registers

Список таблиц

6.1. bin Section Attributes
8.1. ELF Section Attributes
8.2. ELF Standard Sections
14.1. Function Structured Exception Handling Rules
19.1. x86 NOP Padding Modes
19.2. x86 NOP CPU Directive Options
19.3. x86 CPU Feature Flags
19.4. x86 CPU Names

Список примеров

14.1. Win64 Unwind Primitives
14.2. Win64 Unwind Macros