From 8f09f4249cec8ccc187b3f9ee5094fb3080900a9 Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Mon, 1 May 2023 11:00:25 +1000 Subject: memory access thru function; will be vital later. --- headers/instructions/definitions.h | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'headers/instructions/definitions.h') diff --git a/headers/instructions/definitions.h b/headers/instructions/definitions.h index bdeb54e..937ca10 100644 --- a/headers/instructions/definitions.h +++ b/headers/instructions/definitions.h @@ -27,15 +27,15 @@ void fLDY(Addressing addr, address val){ idata = fAddress(addr, val); } void fSTA(Addressing addr, address val){ idata = fAddress(addr, val); - Memory[idata.add] = acc; + setMemory(idata.add, acc); } void fSTX(Addressing addr, address val){ idata = fAddress(addr, val); - Memory[idata.add] = X; + setMemory(idata.add, X); } void fSTY(Addressing addr, address val){ idata = fAddress(addr, val); - Memory[idata.add] = Y; + setMemory(idata.add, Y); } // Arithmetic Instructions @@ -71,7 +71,9 @@ void fSBC(Addressing addr, address val){ idata = fAddress(addr, val); //Increment and Decrement Instructions void fINC(Addressing addr, address val){ idata = fAddress(addr, val); - Memory[idata.add]++; + byte a = getMemory(idata.add); + a++; + setMemory(idata.add, a); setFlagN(Memory[idata.add]); setFlagZ(Memory[idata.add]); } @@ -89,7 +91,9 @@ void fINY(Addressing addr, address val){ idata = fAddress(addr, val); } void fDEC(Addressing addr, address val){ idata = fAddress(addr, val); - Memory[idata.add]--; + byte a = getMemory(idata.add); + a--; + setMemory(idata.add, a); setFlagN(Memory[idata.add]); setFlagZ(Memory[idata.add]); } @@ -195,11 +199,12 @@ void fCPY(Addressing addr, address val){ idata = fAddress(addr, val); } } -//Need to double check the function of this instruction +//NEED TO DOUBLE CHECK THIS INSTRUCTION void fBIT(Addressing addr, address val){ idata = fAddress(addr, val); - setFlag(flag_N, (Memory[val] & flag_N)); - setFlag(flag_V, (Memory[val] & flag_V)); - if (((Memory[val] & flag_N) & (Memory[val] & flag_V)) == 0) { + setFlag(flag_N, (idata.value & flag_N)); + setFlag(flag_V, (idata.value & flag_V)); + + if (((idata.value & flag_N) & (idata.value & flag_V)) == 0) { flagSet(flag_Z); } else { flagSet(flag_Z); @@ -275,26 +280,27 @@ void fTXS(Addressing addr, address val){ idata = fAddress(addr, val); } void fPHA(Addressing addr, address val){ idata = fAddress(addr, val); - Memory[0x01FF-S] = acc; + setMemory(0x01FF-S, acc); S++; } void fPHP(Addressing addr, address val){ idata = fAddress(addr, val); - Memory[0x01FF-S] = P; + setMemory(0x01FF-S, P); S++; } void fPLA(Addressing addr, address val){ idata = fAddress(addr, val); S--; - acc = Memory[0x01FF-S]; + acc = getMemory(0x01FF-S); } void fPLP(Addressing addr, address val){ idata = fAddress(addr, val); S--; - P = Memory[0x01FF-S]; + P = getMemory(0x01FF-S); } // Subroutine Instructions +// NEED TO FINISH THESE void fJSR(Addressing addr, address val){ idata = fAddress(addr, val); Memory[0x01FF-S] = (idata.add-1); -- cgit v1.2.3