[Coco] replicating bitwise operators in BASIC
dave at davebiz.com
Fri Sep 9 14:36:54 EDT 2016
Well, ok, it doesn't have a specific operator called 'NAND'. It has NOT
and AND. Therefore A NAND B is: NOT (A AND B).
Try this on your CoCo to computer XOR (it uses only NOT and AND, which
10 A = 0: B = 0: GOSUB 100
20 A = 1: B = 0: GOSUB 100
30 A = 0: B = 1: GOSUB 100
40 A = 1: B = 1: GOSUB 100
100 Q = NOT ( NOT ( NOT ( A AND B ) AND A ) AND NOT ( NOT ( A AND B )
AND B ) )
110 PRINT "A = ";A;" B = ";B;" Q = ";Q
This is not the shortest way to perform an XOR with the CoCo but it does
demonstrate that an XOR can be performed with just NOT and AND (NAND).
On 9/9/2016 1:09 PM, Barry Nelson wrote:
> Well you could, if Extended Color Basic had a NAND operator. To my knowledge
> it does not.
>> Dave Philipsen dave at davebiz.com
> Fri Sep 9 13:19:10 EDT 2016
>> Well, actually NAND _is_ NOT and AND. And you can actually do it
>> with just NAND.
More information about the Coco