Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created July 17, 2013 16:40
Show Gist options
  • Save AlexArchive/6022271 to your computer and use it in GitHub Desktop.
Save AlexArchive/6022271 to your computer and use it in GitHub Desktop.
Demo: Using Methods in IL
.assembly extern mscorlib {}
.assembly Test
{
.ver 1:0:1:0
}
.module test.exe
.method static void main() cil managed
{
.maxstack 2
.entrypoint
ldc.i4 10
ldc.i4 20
call int32 DoSum(int32, int32)
call void PrintSum(int32)
ret
}
.method public static int32 DoSum(int32 , int32 ) cil managed
{
.maxstack 2
ldarg.0
ldarg.1
add
ret
}
.method public static void PrintSum(int32) cil managed
{
.maxstack 2
ldstr "The Result is: "
call void [mscorlib]System.Console::Write(string)
ldarg.0
call void [mscorlib]System.Console::Write(int32)
ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment