CIL - Instruction set reference with examples

This table is a work in progress.


Contents


Load and Store operations

stloc.0
stloc.1
stloc.2
stloc.3

Pop a value from the evaluation stack into local variable number 0.


  // C#
  var str = "cat";
  
  // MSIL
  ldstr "cat"
  stloc.0
  

The compiler will use this form of stloc to write to the first 4 local variables.

stloc [uint16 index]
stloc.s [uint8 index]
(s = short form)

Pop a value from the evaluation stack into local variable number [index].


  // C#
  ...
  var localVariableNumber10 = "hello10";
  ...
  var localVariableNumber256 = "hello256";
  
  // MSIL
  ldstr "hello10"
  stloc.s 0A
  
  ldstr "hello256"
  stloc 00 01
  

The compiler will use the short form to write to local variables numbered 4 through 255.
It will use the long form of stloc for all remaining local variables.


Ads by Google


Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath