diff --git a/include/c64/iecbus.c b/include/c64/iecbus.c index 1a93755a..aef034a5 100644 --- a/include/c64/iecbus.c +++ b/include/c64/iecbus.c @@ -233,6 +233,28 @@ void iec_close(char dev, char sec) iec_unlisten(); } +int iec_write_bytes(const char * data, int num) +{ + for(int i=0; i= 4) + { + int si = at - 4; + + while (si >= 0) + { + if (mIns[si + 3].ReferencesZeroPage(mIns[at].mAddress)) + { + if (mIns[si + 0].mType == ASMIT_CLC && + mIns[si + 1].mType == ASMIT_LDA && mIns[si + 1].mMode == ASMIM_ZERO_PAGE && + mIns[si + 2].mType == ASMIT_ADC && mIns[si + 2].mMode == ASMIM_IMMEDIATE && (mIns[si + 2].mAddress >= 0 && mIns[si + 2].mAddress <= 4) && + mIns[si + 3].mType == ASMIT_STA && !(mIns[si + 3].mLive & (LIVE_CPU_REG_A | LIVE_CPU_REG_C))) + { + int i = si + 4; + while (i < at && !mIns[i].ChangesZeroPage(mIns[si + 1].mAddress)) + i++; + if (i != at) + return false; + + AsmInsType t = mIns[at].mType == ASMIT_LDX ? ASMIT_INX : ASMIT_INY; + + mIns[at].mAddress = mIns[si + 1].mAddress; + for (int i = 0; i < mIns[si + 2].mAddress; i++) + mIns.Insert(at + 1, NativeCodeInstruction(mIns[si].mIns, t)); + + mIns[si + 0].mType = ASMIT_NOP; mIns[si + 0].mMode = ASMIM_IMPLIED; + mIns[si + 1].mType = ASMIT_NOP; mIns[si + 1].mMode = ASMIM_IMPLIED; + mIns[si + 2].mType = ASMIT_NOP; mIns[si + 2].mMode = ASMIM_IMPLIED; + mIns[si + 3].mType = ASMIT_NOP; mIns[si + 3].mMode = ASMIM_IMPLIED; + + return true; + } + else + return false; + } + + si--; + } + + } + + return false; +} + bool NativeCodeBasicBlock::CombineImmediateADCUp(int at) { int addr = mIns[at].mAddress; @@ -34379,6 +34434,18 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass } CheckLive(); +#endif + +#if 1 + for (int i = 0; i < mIns.Size(); i++) + { + if ((mIns[i + 0].mType == ASMIT_LDX || mIns[i + 0].mType == ASMIT_LDY) && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && !(mIns[i + 0].mLive & LIVE_MEM)) + { + if (MoveSimpleADCToINCDECDown(i)) + changed = true; + } + } + #endif // diff --git a/oscar64/NativeCodeGenerator.h b/oscar64/NativeCodeGenerator.h index 61a36873..aab4dafb 100644 --- a/oscar64/NativeCodeGenerator.h +++ b/oscar64/NativeCodeGenerator.h @@ -442,6 +442,8 @@ class NativeCodeBasicBlock bool MoveTXADCDown(int at); bool FoldShiftORAIntoLoadImmUp(int at); + bool MoveSimpleADCToINCDECDown(int at); + bool MoveZeroPageCrossBlockUp(int at, const NativeCodeInstruction & lins, const NativeCodeInstruction & sins); bool ShortcutCrossBlockMoves(NativeCodeProcedure* proc);