diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-05-01 11:00:25 +1000 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-05-01 11:00:25 +1000 |
commit | 8f09f4249cec8ccc187b3f9ee5094fb3080900a9 (patch) | |
tree | fef74c955ebba3c7815e2981857a07c95b1a97c9 /headers/instructions/definitions.h | |
parent | 138bb8eeb4b67ab17a6d77e7afa9cd265759da0d (diff) |
memory access thru function; will be vital later.
Diffstat (limited to 'headers/instructions/definitions.h')
-rw-r--r-- | headers/instructions/definitions.h | 32 |
1 files changed, 19 insertions, 13 deletions
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); |