document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. private void Execute(byte opCode)
  2.         {
  3.             byte low;
  4.             byte high;
  5.  
  6.             switch (opCode)
  7.             {
  8.                 // LDA immediate addressing
  9.                 case 0xA9:
  10.                     // Read the next byte only
  11.                     reg_A = GetNextMem();
  12.                     break;
  13.  
  14.                 // STA absolute addressing
  15.                 case 0x8D:
  16.                     // Get the address location to store
  17.                     low = GetNextMem();
  18.                     high = GetNextMem();
  19.  
  20.                     // And store it
  21.                     // (We left-shift the high byte by 8 bits and add the low byte to give our 16-bit address)
  22.                     MemoryWrite((UInt16)(high << 8 | low), reg_A);
  23.                     break;
  24.  
  25.                 // STX absolute addressing
  26.                 case 0x8E:
  27.                     // Get the address location to store
  28.                     low = GetNextMem();
  29.                     high = GetNextMem();
  30.  
  31.                     // And store it
  32.                     // (We left-shift the high byte by 8 bits and add the low byte to give our 16-bit address)
  33.                     MemoryWrite((UInt16)(high << 8 | low), reg_X);
  34.                     break;
  35.  
  36.                 // STY absolute addressing
  37.                 case 0x8F:
  38.                     // Get the address location to store
  39.                     low = GetNextMem();
  40.                     high = GetNextMem();
  41.  
  42.                     // And store it
  43.                     // (We left-shift the high byte by 8 bits and add the low byte to give our 16-bit address)
  44.                     MemoryWrite((UInt16)(high << 8 | low), reg_Y);
  45.                     break;
  46.  
  47.                 // PHA - Push Accumlator
  48.                 case 0x48:
  49.                     push_stack(reg_A);  // Push the contents of the accumulator onto the stack
  50.                     break;
  51.  
  52.                 // PHP - Push Status Register (status flags)
  53.                 case 0x08:
  54.                     push_stack(SR);     // Push the contents of the SR onto the stack
  55.                     break;
  56.  
  57.                 case 0x00:
  58.                 // drop through
  59.  
  60.                 default:
  61.                     isExecuting = false;
  62.                     break;
  63.             }
  64.         }
');