Fix crash on late const typecast to pointer

This commit is contained in:
drmortalwombat 2024-06-15 13:35:17 +02:00
parent 3770a05aee
commit 58361e39b8
2 changed files with 20 additions and 4 deletions

View File

@ -103,19 +103,19 @@ static bool iec_writeb(char b)
while (!data_in()); while (!data_in());
delay(5);
for(char i=0; i<8; i++) for(char i=0; i<8; i++)
{ {
delay(8);
clock_false(); clock_false();
delay(8); delay(4);
if (b & 1) if (b & 1)
data_true(); data_true();
else else
data_false(); data_false();
clock_true(); clock_true();
b >>= 1; b >>= 1;
delay(4);
} }
delay(8);
clock_false(); clock_false();
data_true(); data_true();

View File

@ -5020,6 +5020,22 @@ bool InterInstruction::ConstantFolding(void)
return true; return true;
} }
break; break;
case IC_TYPECAST:
if (mSrc[0].mTemp < 0)
{
if (mDst.mType == IT_POINTER && IsIntegerType(mSrc[0].mType))
{
mCode = IC_CONSTANT;
mConst.mType = IT_POINTER;
mConst.mMemory = IM_ABSOLUTE;
mConst.mIntConst = mSrc[0].mIntConst;
mConst.mLinkerObject = nullptr;
mConst.mOperandSize = 2;
mNumOperands = 0;
return true;
}
}
break;
case IC_LOAD_TEMPORARY: case IC_LOAD_TEMPORARY:
if (mDst.mTemp == mSrc[0].mTemp) if (mDst.mTemp == mSrc[0].mTemp)
{ {
@ -21000,7 +21016,7 @@ void InterCodeProcedure::Close(void)
{ {
GrowingTypeArray tstack(IT_NONE); GrowingTypeArray tstack(IT_NONE);
CheckFunc = !strcmp(mIdent->mString, "_menuShowSprites"); CheckFunc = !strcmp(mIdent->mString, "main");
CheckCase = false; CheckCase = false;
mEntryBlock = mBlocks[0]; mEntryBlock = mBlocks[0];