From cee280184747bf189676d2f61340966a0d18a6d5 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sun, 3 Nov 2024 15:36:53 +0100 Subject: [PATCH] Fixed negative offset leas --- oscar64/InterCode.cpp | 12 ++++++++++++ oscar64/NativeCodeGenerator.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index fa3ec5e..4525600 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -19925,6 +19925,18 @@ bool InterCodeBasicBlock::PeepholeReplaceOptimization(const GrowingVariableArray changed = true; } #endif +#if 1 + else if ( + mInstructions[i + 0]->mCode == IC_BINARY_OPERATOR && mInstructions[i + 0]->mOperator == IA_SUB && mInstructions[i + 0]->mSrc[0].mTemp < 0 && + mInstructions[i + 1]->mCode == IC_LEA && mInstructions[i + 1]->mSrc[1].mTemp < 0 && mInstructions[i + 1]->mSrc[0].mTemp == mInstructions[i + 0]->mDst.mTemp && mInstructions[i + 1]->mSrc[0].mFinal) + { + mInstructions[i + 1]->mSrc[0] = mInstructions[i + 0]->mSrc[1]; + mInstructions[i + 1]->mSrc[1].mIntConst -= mInstructions[i + 0]->mSrc[0].mIntConst; + + mInstructions[i + 0]->mCode = IC_NONE; mInstructions[i + 0]->mNumOperands = 0; + changed = true; + } +#endif #if 1 else if ( mInstructions[i + 0]->mCode == IC_LEA && mInstructions[i + 0]->mSrc[0].mTemp < 0 && diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 0774283..37efdf2 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -51718,7 +51718,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc) mInterProc = proc; mInterProc->mLinkerObject->mNativeProc = this; - CheckFunc = !strcmp(mInterProc->mIdent->mString, "Level::method"); + CheckFunc = !strcmp(mInterProc->mIdent->mString, "status_draw_map"); int nblocks = proc->mBlocks.Size(); tblocks = new NativeCodeBasicBlock * [nblocks];