diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index a85d6f2..e24bc69 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -38900,7 +38900,6 @@ void NativeCodeProcedure::Optimize(void) RebuildEntry(); - #if 1 if (step > 3) { @@ -39055,7 +39054,6 @@ void NativeCodeProcedure::Optimize(void) changed = true; } - #if 1 if (step > 0) { @@ -39075,9 +39073,7 @@ void NativeCodeProcedure::Optimize(void) changed = true; #endif - ResetEntryBlocks(); - ResetVisited(); - mEntryBlock->CollectEntryBlocks(nullptr); + RebuildEntry(); #if _DEBUG ResetVisited(); @@ -39092,11 +39088,7 @@ void NativeCodeProcedure::Optimize(void) } #endif - - - #if 1 - if (step > 5 && !changed) { ResetVisited(); @@ -39175,7 +39167,6 @@ void NativeCodeProcedure::Optimize(void) #endif } #endif - if (step > 4 && !changed) { ResetVisited(); @@ -39292,7 +39283,6 @@ void NativeCodeProcedure::Optimize(void) changed = true; #endif - #if 1 if (step >= 5) { @@ -39346,7 +39336,6 @@ void NativeCodeProcedure::Optimize(void) changed = true; #endif - #if 1 ResetVisited(); if (mEntryBlock->ForwardZpXIndex(step >= 5)) diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 6854486..ddd2f97 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -2275,15 +2275,18 @@ Expression* Parser::ParseStatement(void) if ((initExp->mType == EX_ASSIGNMENT || initExp->mType == EX_INITIALIZATION) && initExp->mLeft->mType == EX_VARIABLE && initExp->mRight->mType == EX_CONSTANT && (iterateExp->mType == EX_POSTINCDEC || iterateExp->mType == EX_PREINCDEC || iterateExp->mType == EX_ASSIGNMENT && iterateExp->mToken == TK_ASSIGN_ADD && iterateExp->mRight->mType == EX_CONSTANT) && iterateExp->mLeft->IsSame(initExp->mLeft) && - conditionExp->mType == EX_RELATIONAL && conditionExp->mToken == TK_LESS_THAN && conditionExp->mLeft->IsSame(initExp->mLeft) && conditionExp->mRight->mType == EX_CONSTANT) + conditionExp->mType == EX_RELATIONAL && (conditionExp->mToken == TK_LESS_THAN || conditionExp->mToken == TK_GREATER_THAN) && conditionExp->mLeft->IsSame(initExp->mLeft) && conditionExp->mRight->mType == EX_CONSTANT) { if (initExp->mRight->mDecValue->mType == DT_CONST_INTEGER && conditionExp->mRight->mDecValue->mType == DT_CONST_INTEGER) { int startValue = int(initExp->mRight->mDecValue->mInteger); int endValue = int(conditionExp->mRight->mDecValue->mInteger); int stepValue = 1; + if (iterateExp->mType == EX_ASSIGNMENT) stepValue = int(iterateExp->mRight->mDecValue->mInteger); + else if (iterateExp->mToken == TK_DEC) + stepValue = -1; if (unrollPage) {