The IL Assembly Language Programmers' Reference Beta 1 Release
Common Language Runtime
Common Language Runtime
The IL Assembly Language
Programmers’ Reference
Copyright 2000 Microsoft Corporation. All rights reserved.
Last updated: 03 October 2000
This is preliminary documentation and subject to change.
Page 1
The IL Assembly Language Programmers' Reference Beta 1 Release
Table of Contents
1 Introduction......................................................................................................................9
1.1 Audience 9
1.2 Overview 9
1.2.1 Structure of the Document 10
1.2.2 Text Style 11
1.3 The Execution Engine and the .NET Framework 11
1.4 Validation and Verification 12
1.5 Common Language Specification 13
1.6 The .NET SDK IL Tools 13
1.6.1 The Assembler: ilasm 14
1.6.2 The Disassembler: ildasm 15
1.6.3 The Assembly Linker: al 18
1.6.4 The Stand-alone Verifier: PEVerify 19
1.6.5 The Debugger: cordbg 20
1.6.6 Compilers 20
2 Introductory Examples...................................................................................................21
2.1 Hello World Example 21
2.2 Examples 21
3 General Syntax...............................................................................................................22
3.1 General Syntax Notation 22
3.2 Terminals 22
3.3 Identifiers 23
3.4 Labels and Lists of Labels 24
3.5 Lists of Hex Bytes 25
3.6 Floating point numbers 25
3.7 Source Line Information 25
3.8 File Names 26
3.9 Attributes and Metadata 26
4 Assemblies, Manifests and Modules..............................................................................27
4.1 Assemblies, Modules, Types and Namespaces 27
4.2 IL Assembly Files 27
4.3 Defining an Assembly 28
4.3.1 Operational Characteristics of Assemblies 30
4.3.2 Information about the Assembly 31
Page 2
The IL Assembly Language Programmers' Reference Beta 1 Release
4.3.3 Manifest Resources 32
4.3.4 Files in the Assembly 33
4.4 Referencing Assemblies 33
4.5 Declaring Modules 35
4.6 Referencing Modules 35
4.7 Declarations inside a Module or Assembly 36
4.8 Export Declarations 36
4.8.1 The .comtype directive 37
5 Types..............................................................................................................................38
5.1 Introduction to Types38
5.2 The Type System 40
5.3 Types 41
5.3.1 modreq and modopt 43
5.3.2 pinned 43
5.3.3 Types in Reflection Emit 43
5.4 Built-in Types 43
5.5 Type References, Assemblies and Modules 45
5.6 Inheritance and Subtyping 46
5.6.1 Verification of Subtyping 47
5.6.2 Conformance and Subtyping at Runtime 47
5.7 Native Data Types 47
5.8 Marshaling 50
5.8.1 Marshaling with Reflection 51
6 Visibility, Accessibility and Hiding...............................................................................52
6.1 Visibility 52
6.2 Hiding 52
6.3 Accessibility 53
6.3.1 Family Access 53
6.3.2 Privatescope Access 55
7 Class Types....................................................................................................................56
7.1 Namespaces 56
7.2 Using Classes57
7.3 Instantiating Classes 58
7.4 Defining a Class 58
7.4.1 Class Head 58
7.4.2 Built-in Class Attributes 59
Page 3
The IL Assembly Language Programmers' Reference Beta 1 Release
7.5 Body of a Class 62
7.6 Members of Classes 63
7.6.1 Static and Instance Fields 63
7.6.2 Static and Instance Methods 64
7.6.3 Virtual Methods 64
7.6.4 Method Implementation Requirements66
7.6.5 Instance constructors 67
7.6.6 Instance Finalizer 68
7.6.7 Type Initializers 69
7.7 Nested Classes 71
7.8 Controlling Layout and Dispatch 72
7.8.1 Layout Control of Fields 72
7.8.2 Controlling Virtual Method Dispatch 73
7.9 Global Fields and Methods 74
8 Interfaces........................................................................................................................76
8.1 Implementing Interfaces 76
8.1.1 Implementation Requirements 77
8.1.2 MethodImpls 78
8.2 Defining Interfaces 78
9 Value Types...................................................................................................................80
9.1 Referencing Value Types 81
9.2 Instantiating Value Types 81
9.3 Defining Value Types 82
9.4 Methods of Value Types 83
9.5 Boxing and Unboxing 84
9.6 Copy Constructors on Value Types 86
9.7 Using Value Types for C++ Classes 87
9.7.1 Representation of a Class as a Value Type 87
9.7.2 Representation of the VTable 88
10 Special Types...............................................................................................................89
10.1 Arrays 89
10.1.1 Vectors 89
10.1.2 General Arrays 91
10.1.3 Arrays of Arrays 95
10.2 Enumerations 98
10.3 Pointer Types 99
Page 4
The IL Assembly Language Programmers' Reference Beta 1 Release
10.3.1 Obtaining and Using an Address 101
10.3.2 Unmanaged Pointers 101
10.3.3 Managed Pointers 102
10.3.4 Transient Pointers 103
10.4 Method Pointer Types 103
10.5 Delegates 104
10.5.1 Declaring Delegates 105
10.5.2 Creating Delegates 106
10.5.3 Using Delegates 107
10.5.4 Multicast Delegates 110
10.5.5 Other Methods of Delegates 111
11 Methods......................................................................................................................112
11.1 Method Descriptors 113
11.2 Method Signatures 113
11.3 Types of methods 114
11.3.1 Static Methods 114
11.3.2 Instance Methods 114
11.3.3 Virtual Methods 115
11.4 Method Calls 115
11.4.1 Calling Convention 116
11.4.2 Call Kinds 117
11.4.3 The call Instruction 117
11.4.4 The callvirt Instruction 118
11.4.5 Indirect Calls 119
11.4.6 Tail Calls 120
11.4.7 jmp and jmpi 121
11.4.8 Calling Instance Constructors 122
11.4.9 Calling vararg Methods 123
11.5 Defining Methods 123
11.5.1 Method Head 123
11.5.2 Method Parameters 124
11.5.3 Method Body 126
11.5.4 Predefined Attributes on Methods 130
11.5.5 Implementation Attributes of Methods 132
11.5.6 Scope Blocks 134
11.5.7 vararg Methods 135
Page 5