Example #1
0
 public FlagSet And(FlagSet toCompare) => new FlagSet()
 {
     // Perform a bitwise AND on every flag(in the sense that ON == 1, OFF | UNDEFINED == 0).
     // If both flags of a kind are ON in $toCompare and $this, that flag will be ON in the result. Otherwise, it will be OFF(no UNDEFINED).
     Carry     = (Carry & toCompare.Carry) == FlagState.ON ? FlagState.ON : FlagState.OFF,
     Overflow  = (Overflow & toCompare.Overflow) == FlagState.ON ? FlagState.ON : FlagState.OFF,
     Sign      = (Sign & toCompare.Sign) == FlagState.ON ? FlagState.ON : FlagState.OFF,
     Zero      = (Zero & toCompare.Zero) == FlagState.ON ? FlagState.ON : FlagState.OFF,
     Auxiliary = (Auxiliary & toCompare.Auxiliary) == FlagState.ON ? FlagState.ON : FlagState.OFF,
     Parity    = (Parity & toCompare.Parity) == FlagState.ON ? FlagState.ON : FlagState.OFF,
     Direction = (Direction & toCompare.Direction) == FlagState.ON ? FlagState.ON : FlagState.OFF,
     Interrupt = (Interrupt & toCompare.Interrupt) == FlagState.ON ? FlagState.ON : FlagState.OFF
 };
Example #2
0
        private Context(Context toClone)
        {
            // Create a deep copy of each member in the context
            // This means that each variable will have a different instance, but with the same data as that of $toClone
            // If this wasn't used, changing addresses in $this.Memory would change the same addresses in $toClone.Memory
            // as with $Breakpoints and $Registers. However this isn't necessary for $Flags and $InstructionPointer because
            // they are value types--a deep copy is taken regardless.

            Flags = toClone.Flags;
            InstructionPointer = toClone.InstructionPointer;
            Memory             = toClone.Memory.DeepCopy();
            Breakpoints        = toClone.Breakpoints.DeepCopy();
            Registers          = toClone.Registers.DeepCopy();
        }
Example #3
0
 public FlagSet Overlap(FlagSet input) => new FlagSet()
 {
     // Return a new flag set based on $this and $input.
     // If a flag in $input is FlagState.UNDEFINED, the value of that flag in $this is used instead(which could also be FlagState.UNDEFINED)
     // Otherwise, that flag in the returned FlagSet is equal to the same flag in $input.
     // For example,
     //  $Input.Carry == FlagState.UNDEFINED
     //  $this.Carry == FlagState.ON
     //  New Carry = FlagState.ON
     // Another example,
     //  $Input.Overflow == FlagState.ON
     //  $this.Overflow == FlagState.OFF
     //  New Carry = FlagState.ON
     Carry     = input.Carry == FlagState.UNDEFINED ? Carry : input.Carry,
     Auxiliary = input.Auxiliary == FlagState.UNDEFINED ? Auxiliary : input.Auxiliary,
     Overflow  = input.Overflow == FlagState.UNDEFINED ? Overflow : input.Overflow,
     Zero      = input.Zero == FlagState.UNDEFINED ? Zero : input.Zero,
     Sign      = input.Sign == FlagState.UNDEFINED ? Sign : input.Sign,
     Parity    = input.Parity == FlagState.UNDEFINED ? Parity : input.Parity,
     Direction = input.Direction == FlagState.UNDEFINED ? Direction : input.Direction,
     Interrupt = input.Interrupt == FlagState.UNDEFINED ? Interrupt : input.Interrupt
 };
Example #4
0
 public void Set(FlagState setTo)
 {
     // Change all the flags in the struct to $setTo
     this = new FlagSet(setTo);
 }
Example #5
0
 public bool EqualsOrUndefined(FlagSet toCompare)
 {
     // Return whether two flag sets have the same flags set ON. OFF and UNDEFINED are treat as the same.
     return(toCompare.And(this).ToString() == ToString());
 }