summaryrefslogtreecommitdiff
path: root/instruction.h
diff options
context:
space:
mode:
Diffstat (limited to 'instruction.h')
-rw-r--r--instruction.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/instruction.h b/instruction.h
index af48ba0..054e629 100644
--- a/instruction.h
+++ b/instruction.h
@@ -27,9 +27,36 @@ void fSTY(Addressing addr, int val){
Memory[(fAddressing(addr, val))] = Y;
}
+// Arithmetic Instructions
+void fADC(Addressing addr, int val){
+ int buffer = acc + fAddressing(addr, val);
+ setFlagV(buffer, acc);
-// Arithmetic Instructions
+ if (buffer > 255){
+ setFlag(flag_C, 1);
+ }else{
+ setFlag(flag_C, 0);
+ }
+
+ acc += fAddressing(addr, val);
+ setFlagN(acc);
+ setFlagZ(acc);
+}
+
+void fSBC(Addressing addr, int val){
+ int buffer = acc - fAddressing(addr, val);
+ setFlagV(buffer, acc);
+
+ if (buffer < 0){
+ setFlag(flag_C, 1);
+ }else{
+ setFlag(flag_C, 0);
+ }
+ acc -= fAddressing(addr, val);
+ setFlagN(acc);
+ setFlagZ(acc);
+}
//Increment and Decrement Instructions
@@ -52,7 +79,7 @@ void fORA(Addressing addr, int val){
void fEOR(Addressing addr, int val){
acc = acc ^ fAddressing(addr, val);
- setFlagN();
+ setFlagN(acc);
setFlagZ(acc);
}
@@ -67,7 +94,7 @@ void fEOR(Addressing addr, int val){
void fASL(Addressing addr, int val){
setFlag(flag_C, (val & 0x80));
acc = (val << 1);
- setFlagN();
+ setFlagN(acc);
setFlagZ(acc);
}