mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-05 15:51:56 +00:00
Fix for loading of sbyte in ldc
This commit is contained in:
parent
69add597d4
commit
ab03580e88
1 changed files with 9 additions and 1 deletions
|
|
@ -289,7 +289,15 @@ namespace Cosmos.IL2CPU {
|
||||||
case OperandType.ShortInlineI:
|
case OperandType.ShortInlineI:
|
||||||
switch (xOpCodeVal) {
|
switch (xOpCodeVal) {
|
||||||
case ILOpCode.Code.Ldc_I4_S:
|
case ILOpCode.Code.Ldc_I4_S:
|
||||||
xILOpCode = new ILOpCodes.OpInt(ILOpCode.Code.Ldc_I4, xOpPos, xPos + 1, xIL[xPos], xCurrentHandler);
|
// x = x & 0xFFFFFFFC;
|
||||||
|
// The above code produces:
|
||||||
|
// ldc.i4.s -4
|
||||||
|
// But its getting loaded into a I4, so we have to "extend" it
|
||||||
|
//
|
||||||
|
// First we have to cast it to a signed byte, so .NET will extend it properly to a uint.
|
||||||
|
sbyte xSVal = (sbyte)xIL[xPos];
|
||||||
|
uint xVal = (uint)xSVal;
|
||||||
|
xILOpCode = new ILOpCodes.OpInt(ILOpCode.Code.Ldc_I4, xOpPos, xPos + 1, xVal, xCurrentHandler);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
xILOpCode = new ILOpCodes.OpInt(xOpCodeVal, xOpPos, xPos + 1, xIL[xPos], xCurrentHandler);
|
xILOpCode = new ILOpCodes.OpInt(xOpCodeVal, xOpPos, xPos + 1, xIL[xPos], xCurrentHandler);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue