Esempio n. 1
0
 public static void Compare(IReadonlyRegister <byte> target, byte operand, IFlags flags)
 {
     flags.Zero      = target.Value == operand;
     flags.Subtract  = true;
     flags.Carry     = target.Value < operand;
     flags.HalfCarry = (target.Value & 0xF) < (operand & 0xF);
 }
Esempio n. 2
0
        // Used for LDHL SP, e and ADD SP, e
        public static void LoadWithSignedOffset(IWriteonlyRegister <ushort> target, IReadonlyRegister <ushort> source, sbyte offset, IFlags flags)
        {
            var old = source.Value;

            target.Value    = (ushort)(source.Value + offset);
            flags.Zero      = false;
            flags.Subtract  = false;
            flags.Carry     = (old & 0xFF) + (offset & 0xFF) >= 0x100;
            flags.HalfCarry = (old & 0xF) + (offset & 0xF) >= 0x10;
        }
Esempio n. 3
0
 public static bool GetBit(this IReadonlyRegister <ushort> s, int index) => s.Value.GetBit(index);
Esempio n. 4
0
 // Aliases
 public static bool GetBit(this IReadonlyRegister <byte> b, int index) => b.Value.GetBit(index);
Esempio n. 5
0
 public static void TestBit(IReadonlyRegister <byte> source, int index, IFlags flags)
 {
     flags.Zero      = !source.GetBit(index);
     flags.Subtract  = false;
     flags.HalfCarry = true;
 }