Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Common Intermediate Language
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example== Below is a basic [["Hello, World!" program]] written in CIL assembler. It will display the string "Hello, world!". <syntaxhighlight lang="csharp"> .assembly Hello {} .assembly extern mscorlib {} .method static void Main() { .entrypoint .maxstack 1 ldstr "Hello, world!" call void [mscorlib]System.Console::WriteLine(string) ret } </syntaxhighlight> The following code is more complex in number of opcodes. ''This code can also be compared with the corresponding code in the article about [[Java bytecode]].'' <syntaxhighlight lang="csharp"> static void Main(string[] args) { for (int i = 2; i < 1000; i++) { for (int j = 2; j < i; j++) { if (i % j == 0) goto outer; } Console.WriteLine(i); outer:; } } </syntaxhighlight> In CIL assembler syntax it looks like this: <syntaxhighlight lang="cpp"> .method private hidebysig static void Main(string[] args) cil managed { .entrypoint .maxstack 2 .locals init (int32 V_0, int32 V_1) ldc.i4.2 stloc.0 br.s IL_001f IL_0004: ldc.i4.2 stloc.1 br.s IL_0011 IL_0008: ldloc.0 ldloc.1 rem brfalse.s IL_001b ldloc.1 ldc.i4.1 add stloc.1 IL_0011: ldloc.1 ldloc.0 blt.s IL_0008 ldloc.0 call void [mscorlib]System.Console::WriteLine(int32) IL_001b: ldloc.0 ldc.i4.1 add stloc.0 IL_001f: ldloc.0 ldc.i4 0x3e8 blt.s IL_0004 ret } </syntaxhighlight> This is just a representation of how CIL looks near the [[virtual machine]] (VM) level. When compiled the methods are stored in tables and the instructions are stored as bytes inside the assembly, which is a [[Portable Executable]] (PE).
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Common Intermediate Language
(section)
Add topic