Remove superfluous rts from inline assembler blocks that end with a jmp
This commit is contained in:
parent
5c66e11ca0
commit
cd77372350
|
@ -2303,7 +2303,13 @@ void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block)
|
|||
else if (mType == ASMIT_JSR && mLinkerObject && (mLinkerObject->mFlags & LOBJF_INLINE))
|
||||
{
|
||||
int pos = block->mCode.Size();
|
||||
for (int i = 0; i < mLinkerObject->mSize - 1; i++)
|
||||
int size = mLinkerObject->mSize;
|
||||
|
||||
// skip RTS on embedding
|
||||
if (mLinkerObject->mData[size - 1] == 0x60)
|
||||
size--;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
block->PutByte(mLinkerObject->mData[i]);
|
||||
for (int i = 0; i < mLinkerObject->mReferences.Size(); i++)
|
||||
{
|
||||
|
|
|
@ -2359,7 +2359,9 @@ Expression* Parser::ParseAssembler(void)
|
|||
vdasm->mBase = dassm;
|
||||
|
||||
Expression* ifirst = new Expression(mScanner->mLocation, EX_ASSEMBLER);
|
||||
Expression* ilast = ifirst;
|
||||
Expression* ilast = ifirst, * ifinal = ifirst;
|
||||
|
||||
bool exitLabel = false;
|
||||
|
||||
ifirst->mDecType = dassm;
|
||||
ifirst->mDecValue = vdasm;
|
||||
|
@ -2381,6 +2383,8 @@ Expression* Parser::ParseAssembler(void)
|
|||
else
|
||||
mScanner->NextToken();
|
||||
|
||||
exitLabel = true;
|
||||
|
||||
Declaration* dec = mScope->Lookup(label);
|
||||
if (dec)
|
||||
{
|
||||
|
@ -2398,6 +2402,8 @@ Expression* Parser::ParseAssembler(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
exitLabel = false;
|
||||
|
||||
ilast->mAsmInsType = ins;
|
||||
mScanner->NextToken();
|
||||
if (mScanner->mToken == TK_EOL || mScanner->mToken == TK_CLOSE_BRACE)
|
||||
|
@ -2506,6 +2512,8 @@ Expression* Parser::ParseAssembler(void)
|
|||
|
||||
offset += AsmInsSize(ilast->mAsmInsType, ilast->mAsmInsMode);
|
||||
|
||||
ifinal = ilast;
|
||||
|
||||
ilast->mRight = new Expression(mScanner->mLocation, EX_ASSEMBLER);
|
||||
ilast = ilast->mRight;
|
||||
}
|
||||
|
@ -2523,8 +2531,17 @@ Expression* Parser::ParseAssembler(void)
|
|||
}
|
||||
}
|
||||
|
||||
ilast->mAsmInsType = ASMIT_RTS;
|
||||
ilast->mAsmInsMode = ASMIM_IMPLIED;
|
||||
if ((ifinal->mAsmInsType == ASMIT_RTS || ifinal->mAsmInsType == ASMIT_JMP) && !exitLabel)
|
||||
{
|
||||
delete ilast;
|
||||
ilast = ifinal;
|
||||
ifinal->mRight = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
ilast->mAsmInsType = ASMIT_RTS;
|
||||
ilast->mAsmInsMode = ASMIM_IMPLIED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
offset = 0;
|
||||
|
|
Loading…
Reference in New Issue