Facts:
The correct encoding for the CIL instruction
rethrow's op-code is the two-byte sequenceFE 1A.OpCodes.Rethrow.Value(which has typeshort) has value0xFE1Aon my little-endian machine.BitConverterhonours the machine's endianness when converting to/from byte sequences.On my little-endian machine,
BitConverter.GetBytes(OpCodes.Rethrow.Value)results in the byte sequence1A FE.
That means, serializing an OpCode.Value on a little-endian machine using BitConverter does not produce the correct encoding for the op-code; the byte order is reversed.
Questions:
Is the byte ordering of
OpCode.Valuedocumented (and if so, where?), or is it an "implementation detail"?Does step 4 above on a big-endian machine also result in the wrong byte ordering? That is, would
OpCodes.Rethrow.Valuebe0x1AFEon a big-endian machine?
FEwill know it is a long version. If it represented the other way around, well then you would have a hard time reading it. - leppieFEhas to appear first in the instruction byte stream. My question is about the byte order of the op-code encodings as stored inOpCode.Value. - stakx - no longer contributing