Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:27:52+00:00 2026-06-10T00:27:52+00:00

Facts: The correct encoding for the CIL instruction rethrow ‘s op-code is the two-byte

  • 0

Facts:

  1. The correct encoding for the CIL instruction rethrow‘s op-code is the two-byte sequence FE 1A.

  2. OpCodes.Rethrow.Value (which has type short) has value 0xFE1A on my little-endian machine.

  3. BitConverter honours the machine’s endianness when converting to/from byte sequences.

  4. On my little-endian machine, BitConverter.GetBytes(OpCodes.Rethrow.Value) results in the byte sequence 1A 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.Value documented (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.Value be 0x1AFE on a big-endian machine?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:27:53+00:00Added an answer on June 10, 2026 at 12:27 am

    I’ve reached the conclusion that serializing an op-code representation based on the OpCode.Value property, i.e.:

    OpCode someOpCode = …;
    byte[] someOpCodeEncoding = BitConverter.GetBytes(someOpCode.Value);
    

    is a bad idea, but not because of the use of BitConverter.GetBytes(short) , whose behaviour is well-documented. The main culprit is the OpCode.Value property, whose documentation is vague in two respects:

    1. It states that this property contains “the value of the immediate operand”, which may or may not refer to the op-code’s encoding; that term doesn’t appear anywhere in the CLI specification.

    2. Even when we assume that it does in fact contain an op-code’s encoding, the documentation says nothing about byte order. (Byte order comes into play when converting between byte[] and short.)

    Why am I basing my argument on MSDN documentation, and not on the CLI standard? Because System.Reflection.Emit is not part of the Reflection Library as defined by the CLI standard. For this reason, I think it’s fairly safe to say that the MSDN reference documentation for this namespace is as close as it gets to an official specification. (But unlike @Hans Passant’s answer, I would not take one step further and claim that the reference source is in any way a specification.)

    Conclusion:

    There are two ways to output the op-code encoding for a given OpCode object:

    • Stay with System.Reflection.Emit functionality and use ILGenerator.Emit(someOpCode). This may be too restrictive in some situations.

    • Create your own mapping between op-code encodings (i.e. byte[] sequences) and the various OpCode objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dimension (SiteItem) has two important facts: perUserClicks perBrowserClicks however, within this
There are circumstances in which the deletion of data representing certain facts necessitates the
Okay,...first the facts. I'm working on an ASP.Net project which validates it's users across
The unicode standard has enough code-points in it that you need 4 bytes to
I have the next two facts loaded in my prolog interpreter: foo(U+V,1). foo(U*V,2). Now
I've been hearing conflicting facts about this topic. What is correct?
Facts I have an mvc project. I am using jquery. The problem $('#ModalData').empty(); is
Facts: I'm running a FB contest where users are entered into a drawing simply
I want to scrape a list of facts from simple website. Each one of
An informative-sounding blog post from 2006 states these facts about using native prepared statements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.