diff options
Diffstat (limited to 'instruction.h')
-rw-r--r-- | instruction.h | 405 |
1 files changed, 405 insertions, 0 deletions
diff --git a/instruction.h b/instruction.h new file mode 100644 index 0000000..af48ba0 --- /dev/null +++ b/instruction.h @@ -0,0 +1,405 @@ +//void fXXX(ADDRESSING addr, int val) + + +// Load and Store Instructions + +void fLDA(Addressing addr, int val){ + acc = fAddressing(addr, val); +} + +void fLDX(Addressing addr, int val){ + X = fAddressing(addr, val); +} + +void fLDY(Addressing addr, int val){ + Y = fAddressing(addr, val); +} + +void fSTA(Addressing addr, int val){ + Memory[(fAddressing(addr, val))] = acc; +} + +void fSTX(Addressing addr, int val){ + Memory[(fAddressing(addr, val))] = X; +} + +void fSTY(Addressing addr, int val){ + Memory[(fAddressing(addr, val))] = Y; +} + + + +// Arithmetic Instructions + +//Increment and Decrement Instructions + + + + +// Logical Instructions + +void fAND(Addressing addr, int val){ + acc = acc & fAddressing(addr, val); + setFlagN(); + setFlagZ(acc); +} + +void fORA(Addressing addr, int val){ + acc = acc | fAddressing(addr, val); + setFlagN(); + setFlagZ(acc); +} + +void fEOR(Addressing addr, int val){ + acc = acc ^ fAddressing(addr, val); + setFlagN(); + setFlagZ(acc); +} + +// Jump, Branch, Compare, and Test Bits + + + + + +// Shift and Rotate Instructions + +void fASL(Addressing addr, int val){ + setFlag(flag_C, (val & 0x80)); + acc = (val << 1); + setFlagN(); + setFlagZ(acc); +} + + +// Transfer Instructions + +// Stack Instructions + +// Subroutine Instructions + +// Set/Reset Insutrctions + +void fCLC(){ + setFlag(flag_C, 0); +} + +void fCLD(){ + setFlag(flag_D, 0); +} + +void fCLI(){ + setFlag(flag_I, 0); +} + +void fCLV(){ + setFlag(flag_V, 0); +} + +void fSEC(){ + setFlag(flag_C, 1); +} + +void fSED(){ + setFlag(flag_D, 1); +} + +void fSEI(){ + setFlag(flag_I, 1); +} + +// NOP/BRK Instructions + + + + + + + +/* Disabled for the purpose of testing functions. +this will become relevant towards the end of project. + + +// Instruction Meta +// Alternative would be to make all functions pointer functions, and then look them up +//according to the code in such a way. It may be more readable that way. +void runInstruction(int code, int val){ + switch(code){ + // 0x0. + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + case 0x0 + // 0x1. + case 0x10 + case 0x11 + case 0x12 + case 0x13 + case 0x14 + case 0x15 + case 0x16 + case 0x17 + case 0x18: fCLC(); + case 0x1 + case 0x1 + case 0x1 + case 0x1 + case 0x1 + case 0x1 + case 0x1 + // 0x2. + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + case 0x2 + // 0x3. + case 0x30 + case 0x31 + case 0x32 + case 0x33 + case 0x34 + case 0x35 + case 0x36 + case 0x37 + case 0x38: fSEC(); + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0x4. + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + // 0x5. + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: fCLI(); + case 0x59: + case 0x5A: + case 0x5B: + case 0x5C: + case 0x5D: + case 0x5E: + case 0x5F: + // 0x6. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0x7. + case 0x70 + case 0x71 + case 0x72 + case 0x73 + case 0x74 + case 0x75 + case 0x76 + case 0x77 + case 0x78: fSEI(); + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0x8. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0x9. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0xA. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0xB. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0xB8: fCLV(); + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0xC. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0xD. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0xD8: fCLD(); + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0xE. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + // 0xF. + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0xF8: fSED(); + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + case 0x + default: //Error + } + +} + +*/
\ No newline at end of file |