Skip to content

Instantly share code, notes, and snippets.

@nedgrady
Created June 23, 2019 12:40
Show Gist options
  • Save nedgrady/6b981df5ae40dcaca5d8392c03448d06 to your computer and use it in GitHub Desktop.
Save nedgrady/6b981df5ae40dcaca5d8392c03448d06 to your computer and use it in GitHub Desktop.
int i = 128;
// Push the value 128 (0x00000080) onto the stack
IL_0001: ldc.i4 80 00 00 00
// Store our 128 at location 0 (where the compiler has chosen for i to live).
IL_0002: stloc.0 // i
System.Console.WriteLine(i + 10);
// Push the value of i back onto the stack.
IL_0007: ldloc.0 // i
// Push 10 (0xA) onto the stack
IL_0008: ldc.i4.s 0A
// Add the two top values, leaving the result on top of the stack
IL_000A: add
// Call the static System.Console.WriteLine method, notice we’re passing a
// parameter by pushing its value onto the stack before a call instruction.
IL_0008: call System.Console.WriteLine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment