private void Execute(byte opCode)
{
byte low;
byte high;
switch (opCode)
{
// LDA immediate addressing
case 0xA9:
// Read the next byte only
reg_A = GetNextMem();
break;
// STA absolute addressing
case 0x8D:
// Get the address location to store
low = GetNextMem();
high = GetNextMem();
// And store it
// (We left-shift the high byte by 8 bits and add the low byte to give our 16-bit address)
MemoryWrite((UInt16)(high << 8 | low), reg_A);
break;
// STX absolute addressing
case 0x8E:
// Get the address location to store
low = GetNextMem();
high = GetNextMem();
// And store it
// (We left-shift the high byte by 8 bits and add the low byte to give our 16-bit address)
MemoryWrite((UInt16)(high << 8 | low), reg_X);
break;
// STY absolute addressing
case 0x8F:
// Get the address location to store
low = GetNextMem();
high = GetNextMem();
// And store it
// (We left-shift the high byte by 8 bits and add the low byte to give our 16-bit address)
MemoryWrite((UInt16)(high << 8 | low), reg_Y);
break;
// PHA - Push Accumlator
case 0x48:
push_stack(reg_A); // Push the contents of the accumulator onto the stack
break;
// PHP - Push Status Register (status flags)
case 0x08:
push_stack(SR); // Push the contents of the SR onto the stack
break;
case 0x00:
// drop through
default:
isExecuting = false;
break;
}
}