From 4fb35a7af20cafb97e568c4e21ee89bf46393c4b Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Mon, 20 May 2024 09:03:41 +0200 Subject: [PATCH] Add error when exceeding assembler limits --- oscar64/Errors.h | 1 + oscar64/InterCode.h | 2 +- oscar64/InterCodeGenerator.cpp | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/oscar64/Errors.h b/oscar64/Errors.h index b2d711a..a19365e 100644 --- a/oscar64/Errors.h +++ b/oscar64/Errors.h @@ -105,6 +105,7 @@ enum ErrorID ERRR_STACK_OVERFLOW, ERRR_INVALID_NUMBER, EERR_OVERLAPPING_DATA_SECTIONS, + EERR_ASSEMBLER_LIMIT, EERR_INVALID_PREPROCESSOR, diff --git a/oscar64/InterCode.h b/oscar64/InterCode.h index 944d09c..34c76c0 100644 --- a/oscar64/InterCode.h +++ b/oscar64/InterCode.h @@ -301,7 +301,7 @@ class InterInstruction public: Location mLocation; InterCode mCode; - InterOperand mSrc[8]; + InterOperand mSrc[12]; InterOperand mDst; InterOperand mConst; InterOperator mOperator; diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index 14031c2..657bab3 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -4055,9 +4055,14 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* lins->mSrc[0].mOperandSize = vdec->mSize; block->Append(lins); - jins->mSrc[jins->mNumOperands].mType = InterTypeOf(vdec->mBase); - jins->mSrc[jins->mNumOperands].mTemp = lins->mDst.mTemp; - jins->mNumOperands++; + if (jins->mNumOperands >= 12) + mErrors->Error(exp->mLocation, EERR_ASSEMBLER_LIMIT, "Maximum number of variables in assembler block exceeded", vdec->mIdent); + else + { + jins->mSrc[jins->mNumOperands].mType = InterTypeOf(vdec->mBase); + jins->mSrc[jins->mNumOperands].mTemp = lins->mDst.mTemp; + jins->mNumOperands++; + } } block->Append(jins);