Created
January 16, 2015 14:52
-
-
Save kamiyaowl/e4694a15bae77003da90 to your computer and use it in GitHub Desktop.
FizzBuzz in IL
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
.assembly extern mscorlib {} | |
.assembly fizzbuzz {} | |
.method static void Main() cil managed { | |
.entrypoint | |
.maxstack 2 | |
.locals init (int32 i, int32 n) | |
ldc.i4 1 | |
ldstr "fizzbuzz max>" | |
call void [mscorlib]System.Console::Write(string) | |
stloc i | |
call string [mscorlib]System.Console::ReadLine() | |
call int32 [mscorlib]System.Int32::Parse(string) | |
stloc n | |
LOOP: | |
ldloc i | |
ldloc n | |
bgt LOOPEND | |
ldloc i | |
ldc.i4 15 | |
rem | |
brfalse FIZZBUZZ | |
ldloc i | |
ldc.i4 5 | |
rem | |
brfalse BUZZ | |
ldloc i | |
ldc.i4 3 | |
rem | |
brfalse FIZZ | |
OTHER: | |
ldloc i | |
box int32 | |
br PRINT | |
FIZZBUZZ: | |
ldstr "FIZZBUZZ" | |
br PRINT | |
BUZZ: | |
ldstr "BUZZ" | |
br PRINT | |
FIZZ: | |
ldstr "FIZZ" | |
br PRINT | |
PRINT: | |
call void [mscorlib]System.Console::WriteLine(object) | |
ldloc i | |
ldc.i4.1 | |
add | |
stloc i | |
br LOOP | |
LOOPEND: | |
ret | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment