[Coco] replicating bitwise operators in BASIC
Melanie and John Mark Mobley
johnmarkmelanie at gmail.com
Mon Sep 12 23:34:41 EDT 2016
The following is untested code...
This is an example of OR logic
A=0:B=1
IF A+B >= 1 THEN C=1 ELSE C=0
This is an example or NOR logic
A-0:B=1
IF A+B >= 1 then C=0 ELSE C=1
This is an of AND logic
A=0:B=1
C=A*B
This is an example if NAND logic
A=0:B=1
C=A*B:IF C=0 THEN C=1 ELSE C=0
This is an example of NOT logic
A=0
IF A=0 then A=1 ELSE A=0
This is an example of XOR logic
A=0:B=1
IF A=0 THEN NA=1 ELSE NA=0
IF B=0 THEN NB=1 ELSE NB=0
IF ((A*NB)+(NA*B)) >=1 THEN C=1 ELSE C=0
This is an example of XNOR logic
A=0:B=1
IF A=0 THEN NA=1 ELSE NA=0
IF B=0 THEN NB=1 ELSE NB=0
IF ((A*B)+(NA*NB)) >=1 THEN C=1 ELSE C=0
-------
A=0:B=1
IF A=0 THEN NA=1 ELSE NA=0
IF B=0 THEN NB=1 ELSE NB=0
AAND = A*B
ANOR = NA*NB
IF AAND = 0 THEN ANAND=1 ELSE ANAND=0
IF ANOR = 0 THEN AOR=1 ELSE AOR=0
IF A*BN THEN K1=0 ELSE K1=1
IF NA*B THEN K2=0 ELSE K2=1
IF K1*K2 THEN XOR=0 ELSE XOR=1
IF XOR THEN XNOR=0 ELSE XNOR=1
John Mark Mobley
More information about the Coco
mailing list