The article, Introduction to IL Assembly Language, is a great resource for those of you who would like to understand IL code (kind of like asm but in .net). IL really gives you a different perspective on computer programming, and you must consider more things in comparison to high level languages like C#.
Currently, I am studying conditional statements. Below, an example of a statement that checks whether the two values in the evaluation stack are equal to each other.
//An example of an if statement.
.assembly extern mscorlib {}
.assembly Test
{
.ver 1:0:1:0
}
.module test.exe
.method static void main() cil managed
{
.maxstack 2
.entrypoint
ldc.i4 30
ldc.i4 40
beq Equal
ldstr "No, they are not equal"
call void [mscorlib]System.Console::WriteLine (string)
br Exit
Equal:
ldstr "Yes, they are equal"
call void [mscorlib]System.Console::WriteLine (string)
Exit:
ret
}
By executing this, the result below would be shown:

Leave a Reply