Created
March 3, 2012 10:17
-
-
Save lemol/1965387 to your computer and use it in GitHub Desktop.
Fazendo loop com Intermediate Language.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.method public static int32 | |
SumBetween(int32, int32) cil managed | |
{ | |
.maxstack 2 | |
.locals init (int32, int32) | |
// uma para o contador, outra para result | |
ldarg.0 | |
stloc.0 // i = lower | |
Loop: | |
ldloc.0 | |
ldarg.1 | |
bgt Done // if (i > higher) | |
ldloc.0 | |
ldloc.1 | |
add | |
stloc.1 // result += i | |
ldloc.0 | |
ldc.i4.1 | |
add | |
stloc.0 // i++ | |
br.s Loop | |
Done: | |
ldloc.1 | |
ret // return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment