Free mag vol1 | Page 730

CHAPTER 18  UNDERSTANDING CIL AND THE ROLE OF DYNAMIC ASSEMBLIES [mscorlib]System.Collections.ArrayList type), the class token is prefixed to the data type (not to be confused with the .class directive!). .method public hidebysig static void MyMethod(int32 inputInt, int32& refInt, class [mscorlib]System.Collections.ArrayList ar, [out] int32& outputInt) cil managed { ... } Examining CIL Opcodes The final aspect of CIL code you’ll examine in this chapter has to do with the role of various operational codes (opcodes). Recall that an opcode is simply a CIL token used to build the implementation logic for a given member. The complete set of CIL opcodes (which is fairly large) can be grouped into the following broad categories: • Opcodes that control program flow • Opcodes that evaluate expressions • Opcodes that access values in memory (via parameters, local variables, etc.) To provide some insight to the world of member implementation via CIL, Table 18-5 defines some of the more useful opcodes that are directly related to member implementation logic, grouped by related functionality. Table 18-5. Various Implementation-Specific CIL Opcodes Opcodes Meaning in Life add, sub, mul, div, rem These CIL opcodes allow you to add, subtract, multiply, and divide two values (rem returns the remainder of a division operation). and, or, not, xor These CIL opcodes allow you to perform bit-wise operations on two values. ceq, cgt, clt These CIL opcodes allow you to compare two values on the stack in various manners. For example: ceq: Compare for equality cgt: Compare for greater than clt: Compare for less than box, unbox These CIL opcodes are used to convert between reference types and value types. ret This CIL opcode is used to exit a method and return a value to the caller (if necessary). 673