处理双 NaN 和 Inf 时的 ILASM 问题

Hon*_*haw 5 .net c# cil ilasm

我创建了一个简单的程序,并初始化了双精度类型值,

var a = double.NaN;

我使用 Visual Studio 2019、.net Framework 4.5 构建项目,并使用 ILDASM.exe 版本 4.0.30319.0 将其反汇编为 .il 文件

IL_0001: ldc.r8 -nan(ind)

但当我尝试使用 ILASM.exe 版本 4.8.3752.0 组装它时出现错误

test.il(65) :错误:IL_0001 中标记“-”处的语法错误:ldc.r8 -nan(ind)

Double.PositiveInfinity 和 Double.NegativeInfinity 也发生了这种情况。有人可以帮忙吗?

Hon*_*haw 4

我从这里找到了错误原因

简单的解决方案就是替换:

ldc.r8 -nan(ind) -> ldc.r8 (00 00 00 00 00 00 F8 FF)

ldc.r8 inf -> ldc.r8 (00 00 00 00 00 00 F0 7F)

ldc.r8 -inf -> ldc.r8 (00 00 00 00 00 00 F0 FF)