X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2FBit.java;h=0e709852777d9c35bcd6cdce7e2331a77cc5f830;hb=eb869bb3f59306fef2f9a028ea53a94b5f1bdd72;hp=804ecc94824a6b74c04aac8bee6a0b1fc4abce8f;hpb=7f37c7b2431309e49a0ee116d1ee6c173272e926;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/Bit.java b/era.mi/src/era/mi/logic/Bit.java index 804ecc94..0e709852 100644 --- a/era.mi/src/era/mi/logic/Bit.java +++ b/era.mi/src/era/mi/logic/Bit.java @@ -13,12 +13,14 @@ public enum Bit public Bit and(Bit other) { - if (equals(Bit.ZERO) || other.equals(Bit.ZERO)) - return Bit.ZERO; - else if (equals(other) && equals(Bit.ONE)) - return Bit.ONE; + if (this == ZERO || other == ZERO) + return ZERO; + else if (this == other && this == ONE) + return ONE; + else if (this == X || other == X) + return X; else - return Bit.X; + return ZERO; } public static Bit or(Bit a, Bit b) @@ -28,12 +30,14 @@ public enum Bit public Bit or(Bit other) { - if (equals(Bit.ONE) || other.equals(Bit.ONE)) - return Bit.ONE; - else if (equals(other) && equals(Bit.ZERO)) - return Bit.ZERO; + if (this == ONE || other == ONE) + return ONE; + else if (this == other && this == ZERO) + return ZERO; + else if (this == X || other == X) + return X; else - return Bit.X; + return ZERO; } public static Bit xor(Bit a, Bit b) @@ -43,11 +47,10 @@ public enum Bit public Bit xor(Bit other) { - if(this == Bit.X || this == Bit.Z - || other == Bit.X || other == Bit.Z) + if(this == X || this == Z || other == X || other == Z) return Bit.X; else - return this == other ? Bit.ZERO : Bit.ONE; + return this == other ? ZERO : ONE; } public Bit not()