Fix loop unrolling changing boundary constant

This commit is contained in:
drmortalwombat 2025-03-11 08:19:49 +01:00
parent 840050738f
commit 1c7d71cadb
2 changed files with 9 additions and 1 deletions

View File

@ -569,6 +569,12 @@ void NativeCodeInstruction::Disassemble(FILE* file) const
case ASMIM_IMMEDIATE: case ASMIM_IMMEDIATE:
fprintf(file, "%s #$%02x", AsmInstructionNames[mType], mAddress); fprintf(file, "%s #$%02x", AsmInstructionNames[mType], mAddress);
break; break;
case ASMIM_IMMEDIATE_ADDRESS:
if (mFlags & NCIF_LOWER)
fprintf(file, "%s #<%s", AsmInstructionNames[mType], AddrName(buffer));
else
fprintf(file, "%s #>%s", AsmInstructionNames[mType], AddrName(buffer));
break;
case ASMIM_ZERO_PAGE: case ASMIM_ZERO_PAGE:
fprintf(file, "%s %s", AsmInstructionNames[mType], AddrName(buffer)); fprintf(file, "%s %s", AsmInstructionNames[mType], AddrName(buffer));
break; break;
@ -53268,7 +53274,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
mInterProc->mLinkerObject->mNativeProc = this; mInterProc->mLinkerObject->mNativeProc = this;
CheckFunc = !strcmp(mIdent->mString, "shipyard_close"); CheckFunc = !strcmp(mIdent->mString, "equipment_random");
int nblocks = proc->mBlocks.Size(); int nblocks = proc->mBlocks.Size();
tblocks = new NativeCodeBasicBlock * [nblocks]; tblocks = new NativeCodeBasicBlock * [nblocks];

View File

@ -10337,6 +10337,7 @@ Expression* Parser::ParseStatement(void)
bexp = bexp->mRight; bexp = bexp->mRight;
bexp->mLeft = dexp; bexp->mLeft = dexp;
conditionExp->mRight->mDecValue = conditionExp->mRight->mDecValue->Clone();
conditionExp->mRight->mDecValue->mInteger = numIterations; conditionExp->mRight->mDecValue->mInteger = numIterations;
if (remain) if (remain)
@ -10364,6 +10365,7 @@ Expression* Parser::ParseStatement(void)
int remain = numSteps % unrollLoop; int remain = numSteps % unrollLoop;
endValue -= remain * stepValue; endValue -= remain * stepValue;
conditionExp->mRight->mDecValue = conditionExp->mRight->mDecValue->Clone();
conditionExp->mRight->mDecValue->mInteger = endValue; conditionExp->mRight->mDecValue->mInteger = endValue;
Expression* unrollBody = new Expression(mScanner->mLocation, EX_SEQUENCE); Expression* unrollBody = new Expression(mScanner->mLocation, EX_SEQUENCE);