NAND and NOR operators

hippy

Technical Support
Staff member
The 4.0.x Basic Commands Manual, and the soon to be 4.1.x revised version, state the following ...

&/ AND NOT ( NAND )
!/ OR NOT ( NOR )
^/ XOR NOT ( XNOR )

That is not correct; "AND NOT" is not "NAND", "OR NOT" is not "NOR". The PICAXE provides "AND NOT" and "OR NOT" operators, but does not provide "NAND" or "NOR" operators.

AND NOT ==> a AND ( NOT b )

a b
0 0 = 0
0 1 = 0
1 0 = 1
1 1 = 0

NAND ==> NOT ( a AND b )

a b
0 0 = 1
0 1 = 1
1 0 = 1
1 1 = 0

OR NOT ==> a OR ( NOT b )

a b
0 0 = 1
0 1 = 0
1 0 = 1
1 1 = 1

NOR ==> NOT ( a OR b )

a b
0 0 = 1
0 1 = 0
1 0 = 0
1 1 = 0

For "XOR NOT" and "XNOR", the output is the same, no matter which fundamental boolean equation is used.

Test code ...

- FOR b1 = 0 TO 1
- FOR b0 = 0 TO 1
- b2 = b1 <b><i>op </i> </b> b0 &amp; 1
- SERTXD ( #b2 )
- NEXT
- NEXT

&amp;/ gives 0010 ( NAND would be 1110 )
!/ gives 1011 ( NOR would be 1000 )
^/ gives 1001

[ Note the ! character should be a vertical bar but the forum won't display vertical bars ]
 
Top