Byte forwardiong optimisation in native mode

This commit is contained in:
drmortalwombat 2021-09-25 23:08:45 +02:00
parent 1dd63ac708
commit 2fc414ed6b
3 changed files with 23 additions and 6 deletions

View File

@ -96,6 +96,12 @@ if %errorlevel% neq 0 goto :error
..\release\oscar64 -e -n loopdomtest.c
if %errorlevel% neq 0 goto :error
..\release\oscar64 -e byteindextest.c
if %errorlevel% neq 0 goto :error
..\release\oscar64 -e -n byteindextest.c
if %errorlevel% neq 0 goto :error
exit /b 0
:error
echo Failed with error #%errorlevel%.

View File

@ -1,5 +1,6 @@
// short index ops
#include <stdio.h>
#include <assert.h>
char a[20];
@ -11,6 +12,7 @@ int main(void)
for(char i=0; i<20; i++)
x += a[i];
printf("Sum %d\n", x);
assert(x == 190);
return 0;
}

View File

@ -779,10 +779,19 @@ bool NativeCodeInstruction::ValueForwarding(NativeRegisterDataSet& data)
switch (mType)
{
case ASMIT_LDA:
if (data.mRegs[CPU_REG_A].mZeroPage && data.mRegs[CPU_REG_A].mValue == mAddress && !(mLive & LIVE_CPU_REG_Z))
if (data.mRegs[CPU_REG_A].mZeroPage && data.mRegs[CPU_REG_A].mValue == mAddress)
{
mType = ASMIT_NOP;
mMode = ASMIM_IMPLIED;
if (mLive & LIVE_CPU_REG_Z)
{
mType = ASMIT_ORA;
mMode = ASMIM_IMMEDIATE;
mAddress = 0;
}
else
{
mType = ASMIT_NOP;
mMode = ASMIM_IMPLIED;
}
changed = true;
}
else if (data.mRegs[mAddress].mImmediate)