"ldc.i4.s" expects an argument of type sbyte.

But it might be better not to emit short forms yourself (especially with
branch instructions, it's tricky to know up ahead if the short form can
be used).
You can emit "ldc.i4" with argument of type int, and call
method.Body.SimplifyMacros() [from Mono.Cecil.Rocks] to convert all
instructions in the method to their short form, if possible.

Daniel

On 8/21/2011 18:42, UbbeLoL wrote:
> So i'm trying to create a small method for one of my applications
> through mono.cecil. I'm not good enough in IL to write it purely from
> my mind so I code the method first in C# use ILDasm to get the IL code
> and then work from there. And in ILDasm's output the opcode "Ldc.i4.s"
> is used with the operand 124, and I later read up on the internet that
> this opcode should be used for pushing integers ranging from -127 to
> 127.
>
> But no matter what I cast the operand it doesn't help, it always gives
> me an "opcode" ArgumentException when trying to emit the instruction.
>
> What should I do?
>
> Thanks,
> UbbeLoL
>


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to