[Coco] replicating bitwise operators in BASIC

Dave Philipsen 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 
is NAND):

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
90 STOP
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
120 RETURN

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).


Dave


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
> <mailto:coco%40maltedmedia.com?Subject=Re%3A%20%5BCoco%5D%20replicating%20bi
> twise%20operators%20in%20BASIC&In-Reply-To=%3C57D2EF0E.8080101%40davebiz.com
> %3E>
> Fri Sep 9 13:19:10 EDT 2016
>
>   
>
>>          Well, actually NAND _is_ NOT and AND.  And you can actually do it
> all
>>          with just NAND.
>   
>
>



More information about the Coco mailing list