From 1c7d71cadb1952e74cb7b4d7daf737ecfe93937a Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Tue, 11 Mar 2025 08:19:49 +0100 Subject: [PATCH] Fix loop unrolling changing boundary constant --- oscar64/NativeCodeGenerator.cpp | 8 +++++++- oscar64/Parser.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index b8709c4..82772ec 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -569,6 +569,12 @@ void NativeCodeInstruction::Disassemble(FILE* file) const case ASMIM_IMMEDIATE: fprintf(file, "%s #$%02x", AsmInstructionNames[mType], mAddress); 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: fprintf(file, "%s %s", AsmInstructionNames[mType], AddrName(buffer)); break; @@ -53268,7 +53274,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc) mInterProc->mLinkerObject->mNativeProc = this; - CheckFunc = !strcmp(mIdent->mString, "shipyard_close"); + CheckFunc = !strcmp(mIdent->mString, "equipment_random"); int nblocks = proc->mBlocks.Size(); tblocks = new NativeCodeBasicBlock * [nblocks]; diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index b91c403..31d7c90 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -10337,6 +10337,7 @@ Expression* Parser::ParseStatement(void) bexp = bexp->mRight; bexp->mLeft = dexp; + conditionExp->mRight->mDecValue = conditionExp->mRight->mDecValue->Clone(); conditionExp->mRight->mDecValue->mInteger = numIterations; if (remain) @@ -10364,6 +10365,7 @@ Expression* Parser::ParseStatement(void) int remain = numSteps % unrollLoop; endValue -= remain * stepValue; + conditionExp->mRight->mDecValue = conditionExp->mRight->mDecValue->Clone(); conditionExp->mRight->mDecValue->mInteger = endValue; Expression* unrollBody = new Expression(mScanner->mLocation, EX_SEQUENCE);