How to rewrite (P or Q) with AND

1.2k Views Asked by At

I'm trying to write a XOR operation in assembly language, but the only operations we're allowed to use are AND and NOT, not OR and definitely not XOR. I have looked everywhere online and I can't seem to find the answer. I know: XOR = (P or Q) and ~(P and Q) But I need to rewrite (P or Q) with an AND operation instead. Is this possible?

1

There are 1 best solutions below

5
On

One of De Morgan's laws(a) states that (using ~ for negation (not), for conjunction (and) and for disjunction (or)):

~A ∨ ~B = ~(A ∧ B)

In your case or P ∨ Q, P is ~A and Q is ~B. So:

P ∨ Q = ~(~P ∧ ~Q)

That right side is therefore the equivalent of P ∨ Q, using only ~ and operations.


(a) And a big thanks for letting me use this knowledge for about the third time since I left University in 1986 :-)