コード例 #1
0
 public static void NEG(Accumulator accumulator, StatusRegister statusRegister)
 {
     int operator1 = accumulator.accumulator;
     byte operator1MSB = (byte)((int)operator1 >> 7);
     accumulator.accumulator = (byte)~accumulator.accumulator;
     accumulator.accumulator++;
     byte resMSB = (byte)((int)accumulator.accumulator >> 7);
     statusRegister.overflow = (operator1MSB == 0) && (0 != resMSB);
     statusRegister.carry = ((operator1 + 1) > 255);
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #2
0
 public static void ADDC(Accumulator accumulator, Registers registers, byte registerAddress, StatusRegister statusRegister)
 {
     ushort operator1 = accumulator.accumulator;
     ushort operator2 = registers.R[registerAddress];
     byte operator1MSB = (byte)((int)operator1 >> 7);
     byte operator2MSB = (byte)((int)operator2 >> 7);
     accumulator.accumulator = (byte)((int)operator1 + operator2 + Convert.ToUInt16(statusRegister.carry));
     byte resMSB = (byte)((int)accumulator.accumulator >> 7);
     statusRegister.overflow = (operator1MSB == operator2MSB) && (operator2MSB != resMSB);
     statusRegister.carry = ((operator1 + operator2 + Convert.ToUInt16(statusRegister.carry)) > 255);
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #3
0
 public static void NOT(Accumulator accumulator, StatusRegister statusRegister)
 {
     accumulator.accumulator = (byte)~accumulator.accumulator;
     resetCarryAndOverflow(statusRegister);
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #4
0
 public static void LDArf(Accumulator accumulator, Registers registers, byte registerAddress, StatusRegister statusRegister)
 {
     accumulator.accumulator = registers.R[registerAddress];
     resetCarryAndOverflow(statusRegister);
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #5
0
 public static void LDI(Accumulator accumulator, byte constant, StatusRegister statusRegister)
 {
     accumulator.accumulator = constant;
     resetCarryAndOverflow(statusRegister);
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #6
0
 private static void setNegativeAndZeroFlags(Accumulator accumulator, StatusRegister statusRegister)
 {
     statusRegister.negative = (accumulator.accumulator & 128) == 128;
     statusRegister.zero = accumulator.accumulator == 0;
 }
コード例 #7
0
 public static void LDAaddr(Accumulator accumulator, Memory memory, byte address, StatusRegister statusRegister)
 {
     accumulator.accumulator = memory.memory[address];
     resetCarryAndOverflow(statusRegister);
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #8
0
 public static void SUB(Accumulator accumulator, Registers registers, byte registerAddress, StatusRegister statusRegister)
 {
     int operator1 = accumulator.accumulator;
     int operator2 = registers.R[registerAddress];
     operator2 = ~operator2++;
     byte accMSb = (byte)((int)accumulator.accumulator >> 7);
     byte regMSb = (byte)((int)registers.R[registerAddress] >> 7);
     accumulator.accumulator += (byte)operator2;
     if (statusRegister.carry)
     {
         accumulator.accumulator++;
     }
     byte resMSb = (byte)((int)accumulator.accumulator >> 7);
     statusRegister.overflow = (accMSb == regMSb) && (resMSb != accMSb);
     statusRegister.carry = ((operator1 + operator2) > 255);
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #9
0
 public static void VADD(Accumulator accumulator, VectorAdderBuffer vectorAdderBuffer, VectorStack vectorStack0, VectorStack vectorStack1, StatusRegister statusRegister)
 {
     ushort operator1 = vectorStack0.pop();
     ushort operator2 = vectorStack1.pop();
     byte operator1MSB = (byte)((int)operator1 >> 7);
     byte operator2MSB = (byte)((int)operator2 >> 7);
     accumulator.accumulator = (byte)((int)operator1 + operator2);
     byte resMSB = (byte)((int)accumulator.accumulator >> 7);
     statusRegister.overflow = (operator1MSB == operator2MSB) && (operator2MSB != resMSB);
     statusRegister.carry = ((operator1 + operator2) > 255);
     setNegativeAndZeroFlags(accumulator, statusRegister);
     vectorAdderBuffer.vectorAdderBuffer = (byte)((int)vectorStack0.pop() + vectorStack1.pop());
 }
コード例 #10
0
 public static void STArf(Registers registers, byte registerAddress, Accumulator accumulator)
 {
     registers.R[registerAddress] = accumulator.accumulator;
 }
コード例 #11
0
 public static void STAaddr(Memory memory, byte address, Accumulator accumulator)
 {
     memory.memory[address] = accumulator.accumulator;
 }
コード例 #12
0
 public static void RRC(Accumulator accumulator, StatusRegister statusRegister)
 {
     byte accLSB = (byte)((int)accumulator.accumulator & 1);
     accumulator.accumulator >>= 1;
     accumulator.accumulator |= (byte)(statusRegister.carry ? 255 : 0);
     statusRegister.carry = accLSB == 1;
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #13
0
 public static void RLC(Accumulator accumulator, StatusRegister statusRegister)
 {
     byte accMSB = (byte)((int)accumulator.accumulator >> 7);
     accumulator.accumulator <<= 1;
     accumulator.accumulator |= (byte)(statusRegister.carry ? 1 : 0);
     statusRegister.carry = accMSB == 1;
     setNegativeAndZeroFlags(accumulator, statusRegister);
 }
コード例 #14
0
 public static void PUSH(VectorStack vectorStack, Accumulator accumulator)
 {
     vectorStack.push(accumulator.accumulator);
 }