Reputation: 740
I wrote an algorithm for computing the multiplication of two binary numbers. In my instruction set, there is no and instruction, just a nand(not and). I read and it logically makes sense that two nands make an and. I feel this is really simple and I'm overthinking it
So for example, if i wanted to compute the and of 3 & 1, how could i do this using two nand operations with two instructions
My ISA executes a Nand like the following and has 8 registers numbered 0-7. For example:
nand 1 2 3 (nand contents in reg1 and reg2 and store in reg3)
Upvotes: 1
Views: 117
Reputation: 50981
NAND is ~(a & b)
so if you give it another ~
, you get an and. If you don't have any NOT gates, you can build one out of NANDs: ~(a & a)
is the same as ~a
. Put it together, and you get
nand r1 r2 r3
nand r3 r3 r3
Upvotes: 2
Reputation: 281167
result = x nand y
result = result nand result
Use the second nand
as a not
.
Upvotes: 3