LOGIC  /ݘ "LOGIC" (1:1:7:49999O  30 #821,0;" PLEASE WAIT " (<N=19 :G$:R=07:B:G$+R,B:R:N 2"A",28,34",33!,28,62>,63?,63?,31,"B",0,0,0,128,64@,32 ,144,200 7"C",15,7,3,1,0,0,0,0,"D",228,242,250,252,254,126~,62>,28 <~"E",0,480,60<,63?,60<,480,0,0,"F",63?,63?,63?,63?,513,33!,0,0,"G",63?,63?,63?,31,31,31,0,0,"H",255,255,255,255,255,255,0,0,"I",255,255,254,252,248,224,0,0 F@C=0242:0,C;"";1,C;"":C PL=2162:L,0;"";L+1,0;"";L,30-(4L=2)-(2L=4);"";L+1,30-(4L=2)-(2L=4);"":L ZBC=0302:18,C;"";19,C;"":C dq3,20;"";4,20;"";5,3;"LONGMAN SOFTWARE ";6,20;"" n9000(#:9000(# xbA$="COMPUTER":L=7:C=3:9180#:A$="STUDIES":L=10 :C=4:9180# 0:1 140 &N=50000P50023g:Z:N,Z:N m33!,0,64@,17,0,228,1,0,27,237,176,201 m33!,0,228,17,0,64@,1,9 ,27,237,176,201 621,0;" " 50000P :21,0;" SEARCHING AND LOADING " &7:1:20,0; ""  #("DOUBLE HEIGHT" #2&N=5005050129:z:N,z:N #<237,75K,176,92\,121y,254,32 ,568,1,201,120x,254,21,568,1,201,205,158,14,197,6,0,9 ,193 #F229,229,120x,60<,205,158,14,6,0,9 ,209,1,0,7,9 ,235,9 ,229,6,4,126~,18,21,18,21,37%,16,248 #P209,6,4,126~,18,21,18,21,37%,16,248,225,124|,15,15,15,230,3,246,88X,103g,126~,1,32 ,0,9 ,119w,201 #"DOUBLE WIDTH" #&N=5015050241A:z:N,z:N #237,75K,176,92\,121y,254,31,568,1,201,120x,254,22,568,1,201,205,158,14,6,0,9 ,229,14 #8,126~,35#,546,0,6,4,15,568,6,203,14,203,14,24,8,203,14,203,14,203,254,203,246 #16,237,43+,546,0,6,4,15,568,6,203,14,203,14,24,8,203,14,203,14,203,254,203,246,16,237,36$,13 ,32 ,203,225,124|,15,15,15,230,3,246,88X,103g,126~,35#,119w,201 # #23729\,L:n=1̱a$ #23728\,c # l,c;a$(n) #50150 #350050:23728\,c+1:50050 #c=c+2:n $ #(bGI ZPzACOMPUTER@logic >C U@,@CZ=50012\:75K "Logic" E 1984 MERCURIAN PULP  PRODUCTS/CONTRACT BOOKS  AA$=" LOGIC ":C=3:7:1:23729\,13 (UN=17:23728\,C:13 ,C;A$(N):Z=50150:Z=50050 2723728\,C+1:Z=50050:C=C+2:N "5"180 a$="1"500:300, a$="2"1000:300, a$="3"1500:300, A$="4"2500 A$="5"340T ,a" ":#1;0,0;"  Press  any key  to go on ":.5,0 6a$=:a$=""3106 @ 100d TG1:Z=50012\:21,8;" END OF PROGRAM ": 1:7:0: (1,9 ;" BINARY BITS " a124|,131:128,0:0,-16:-128,0:0,16 LX=14023616:X,131:7;0,-16:X N6,1;" The BYTE ";6,16;"1 0 0 1 1 0 1 0" 0aw$=z$+" In an 8 BIT computer like the Spectrum, every BYTE has 8 BITS - 8 Binary digiITS. " Dtw$=w$+" Every BIT has a reference number. The BIT NUMBERS run from Right to Left and are numbered 0 to 7."+z$ N 5000 Xc4,1;" BIT NUMBERS ":n=07:4,30-2*n;1;n b31,0:4,30-2*n;n:n lfw$=z$+" Every BIT set to ""1"" has a decimal value. This value is 2 to the power of the BIT number." vCw$=w$+" BIT 1 is worth 2^1 = 2. BIT 4 is worth 2^4 = 16."+z$ 45000:9 ,1;"Decimal value" Mn=07:l=9 -(n/2=(n/2)):c=30-2*n 3l,c;2;"^";l+1,c;1;2^n ,1,5:l+1,c;2^n:n ww$=z$+" To calculate the total value of a BYTE, add together the decimal values of each BIT that is set to ""1""."+z$  5000 (12 ,1;" BYTE total " Q12 ,16;1;"^ ^ ^ ^";13 ,15;"128 + 16+8 +2" -1,5:15,18;"= 154" l#1;0,0;" Do you want to see this again? Press  Y  or  N  " .5,10 -23658j\,8:a$=:a$=""750 a$="Y"500 a$"N"740  " ": 1:7:0: )1,9 ;" LOGICAL BITS " a100d,147:128,0:0,-16:-128,0:0,16 LX=116t21216:X,147:7;0,-16:X J4,1;" BYTE A ";4,13 ;"1 0 0 1 1 0 1 0" a100d,123{:128,0:0,-16:-128,0:0,16 $LX=116t21216:X,123{:7;0,-16:X .J7,1;" BYTE B ";7,13 ;"1 1 0 0 1 0 0 1" 8XW$=Z$+" Computers process numbers by testing the logical relations between the BITS ." B7w$=w$+" This testing is done through LOGIC GATES."+z$ L 5000 V 5100 t{W$=Z$+" The results can be classified in a TRUTH TABLE. Different GATES give different values (0 or 1) in the C column." ~{w$=w$+" It is called a Truth Table because in computer logic a bit set to ""1"" is TRUE. A bit set to ""0"" is FALSE."+z$  5000 11 ,16;" TRUTH TABLE ";13 ,14;" BOTH 0 (FALSE) ";15,14;" DIFFERENT (F/T)";17,14;" DIFFERENT (T/F)";19,14;" BOTH 1 (TRUE) " e1200:n=22683X22669X-2:a:n,a:n+96`,a:.5,8:502:n I480,480,40(,32 ,480,40(,480,32 l#1;0,0;" Do you want to see this again? Press  Y  or  N  " .5,10 .23658j\,8:a$=:a$=""1230 a$="Y"1000 a$"N"1220 " ": 1500:T=15 1:1:0: 0T$:0,9 ;" THE ";T$;" GATE " A7:0:L=27:L,1;Z$(9 ):L 3X=16:Y=143:(4000+100d*T) @3,3;"A";5,3;"B";4,8;"C"  5100 "B$="00011011" ,N=14:4,1;1;B$(N*2-1):.5,0:25:1;6,1;B$(N*2) 6P.5,2:C$:25:5,9 ;1;C$:.5,5 @n502:4,1;0;B$(N*2-1);6,1;B$(N*2);5,9 ;C$ J.5,N*2:502:11 +n*2,9 ;8;1;c$:.5,10 :502:11 +n*2,9 ;8;c$:100d:N TFw$:w$=z$+w$+" Watch the BITS being processed by this gate."+z$ ^ 5000 hCl=27:7;0;l,14;z$(18):l r123{,131:0,24:128,0:0,-24:-128,0:0,-16:128,0:0,16 |Cx=13923516:x,155:0,-40(:x u3,14;"A";3,16;"1 0 1 0 1 0 1 0";4,14;"B";4,16;"1 1 0 0 0 1 1 0" ]c$:n=07:6,30-n*2;1;c$(8-n):.5,0 ]6,30-n*2;7-(3c$(8-n)="1");c$(8-n):502:n W$:w$=z$+W$+z$ El=10 20:7;0;l,16;z$(16):l 0:5200P 34050+100d*t:7:0:0 e11 ,17;"A";11 ,30;"B";19,17;0;19,30;4 ֣14,20;3;16,19;5;14,23;1;16,24;7;14,26;2;16,27;6  5000 w$:w$=z$+w$+z$:5000 T=51,6: ^.5,0:#1;1,0;"  N  for next  O  for new Option" .23658j\,8:a$=:a$=""1780 a$="O"t=5:1810 a$"N"1770 t: "AND","0","0","0","1" @"The BIT in C is ""1"" ONLY if both A and B are ""1"" (TRUE)."  "10000010" A" In this example, the AND gate has set BITS 1 and 7 to ""1""." $"BITS 1 and 7 satisfy (A AND B)." "OR","0","1","1","1" B"The BIT in C is ""1"" if EITHER A OR B ( OR BOTH ) are ""1"". "  "11101110" :" Here BITS 1,2,3,5,6 & 7 have all been set to ""1"". " )"BITS 1,2,3,5,6 & 7 satisfy (A OR B) ."  "NAND","1","1","1","0" *" NAND means NOT AND . It gives the inverse of an AND operation. The BIT in C is set to ""1"" unless both A and B are ""1"". " 4 "01111101" >)" BITS 0,2,3,4,5 & 6 are set to ""1""." C."BITS 0,2,3,4,5 & 6 satisfy NOT (A AND B) ." H"NOR","1","0","0","0" R*"NOR is ""NOT OR"" - the inverse of OR." \ "00010001" f7"Only BITS 0 and 4 are set to ""1"" by the NOR gate." k*"Only BITS 0 & 4 satisfy NOT (A OR B) ." p"X-OR","0","1","1","0" z6"X-OR is Exclusive OR . Either A or B but NOT both."  "01101100" $"BITS 2,3,5 & 6 are set to ""1""." 7"BITS 2,3,5 & 6 satisfy (A OR B) but not (A AND B)." 1:7:0: -1,6;" HOW'S YOUR LOGIC ? " a'" This section will test your"'" understanding of LOGIC GATES,"'" and your logical reasoning." '" You start with 8 separate BITS"'" at 4 Logic gates. The outputs"'" from those gates are fed into"'" 2 more, and on to a final gate." F'" Work your way through the gates"'" giving the outputs as you go." '" Would you like me to correct"'" any mistakes as you make them,"'" or would you prefer to plough"'" on to the end before I tell you"'" how you have done?" i2500 :h(7,5):i(8):j(4,2):k(2,2):l$(5,4) n=15:l$(n):n  "AND","OR","NAND","NOR","X-OR" 4N=17:T=14:H(N,T):T:N (16,156,2,1,16,116t,7,1,16,76L,12 ,1,16,36$,17,1 2p100d,132,5,12 ,100d,524,15,12 ,184,92\,10 ,22 Zl#1;0,0;" Press  F  for instant feedback or  W  to Wait till the end " d.5,0 n.23658j\,8:a$=:a$=""2670n x*f=0:a$="F"f=1:2700 a$"W"2660d SC=0 8:N=17:H(N,5)=(*5)+1 EX=H(N,1):Y=H(N,2):(4000+100d*H(N,5)) FH(N,3)-1,H(N,4)+5;6;L$(H(N,5)) N 80P,144:16,-12 :80P,108l:16,8:80P,64@:16,-12 :80P,28:16,8 Ȓ170,124|:4,0:0,-32 :4,0:170,44,:4,0:0,32 :4,0 &N=18:I(N)=(*2) ?M=((N+1)/2):MX=(2N/2=(N/2)) -H(M,3)+MX,H(M,4);5;I(N) N nN=14:A=I(N*2-1):B=I(N*2):3000 +100d*H(N,5):J(N,1)=C an=j(n,1):3600 J(N,2)=A$:n N=56:A=J(N*2-9 ,2):B=J(N*2-8,2):3000 +100d*H(N,5):K(N-4,1)=C "%an=K(n-4,1):3600 ,K(N-4,2)=A$:N 6`N=7:A=K(1,2):B=K(2,2):3000 +100d*H(N,5):AN=C @A3600:F=0SC<73800:C$=Z$:2930r J=R=0SC=7C$=" !! EXCELLENT LOGIC !! " TMR=0SC<7C$=" MADE IT BUT WITH "+(7-SC)+" MISTAKES. " ^5RSC=6C$=" EVERYONE RIGHT EXCEPT THE LAST " h5RSC<6C$="A LITTLE MORE REVISION IS NEEDED" rr#1;0,0;6;0;C$;1,0;"  A  Another go  O  a new Option" |1,0 .23658j\,8:a$=:a$=""2950 a$="A"2650Z a$"O"2940|  C=0:ABC=1 & C=0:ABC=1  C=1:ABC=0  HC=1:ABC=0 R C=0:AB ABC=1  FH(N,3)+1,H(N,4)+8;"?":.5,0 l#1;0,0;" Press  1  or  0  - don't worry you have a 50% chance of error " $a$=:a$=""3620$ .a$"0"a$"1"3610 82" ":r=1:a$=anr=0:SC=SC+1 =FL=R:F=0fl=0 B<h(n,3)+1,h(n,4)+8;FL;4;a$ L F=0 Vr3700t `<t=13:.2~L,0:.2~L,5:t: t2,-20 ~Ah(n,3)+1,h(n,4)+8;1;7;an  A$=(AN): d#1;0,0;"  YOU MADE SOME MISTAKES. I WILL SHOW YOU WHERE. " :N=14:J(N,1)=J(N,2)3850  BH(N,3)+1,H(N,4)+8;1;J(N,1) 5T=15:.25~,-10 :25:T BH(N,3)+1,H(N,4)+8;1;J(N,1)  N :N=12:K(N,1)=K(N,2)3900< RH(N+4,3)+1,H(N+4,4)+8;1;K(N,1) (5T=15:.25~,-10 :25:T 2RH(N+4,3)+1,H(N+4,4)+8;1;K(N,1) <N F A$=C P11 ,30;1;C Z5T=15:.25~,-10 :25:T d!11 ,30;1;C:  |X,Y:20,0:X,Y-16:20,0:X+20,Y+6:0,-28:0,28,3.6ffff (X+38&,Y-8:16,0 " 6 4 @13 ,23;"";14,22;"";15,22;"";16,22;"";17,22;"";18,23;"": h7x,y:20,0:x,y-16:20,0 rkx+16,y+6:0,-28,-1.5@:22,14,1:-22,14,1 |(x+38&,y-8:16,0  4:4460l: 4:41506:1 12 ,20;"";13 ,19;"";13 ,24;"";14,18;"";14,25;"";15,18;"";15,26;"" 16,18;"";16,26;"";17,18;"";17,25;"";18,19;"";18,24;"";19,20;""  |X,Y:20,0:X,Y-16:20,0:X+20,Y+6:0,-28:0,28,3.6ffff Fx+40(,y-8,2:x+42*,y-8:12 ,0   4370 ,7:4:4160@:5200P: <l=10 20:l,16;4;z$(16):l  07x,y:20,0:x,y-16:20,0 :kx+16,y+6:0,-28,-1.5@:22,14,1:-22,14,1 DFx+40(,y-8,2:x+42*,y-8:12 ,0 N b4370:7:4 l12 ,20;"";13 ,19;"";14,18;"";15,18;"" v16,18;"";17,18;"";18,19;"";19,20;"" 1:4700\: kx,y:16,0:x,y-16:16,0:X+12 ,Y+6:0,-28,-1.5@ kx+16,y+6:0,-28,-1.5@:22,14,1:-22,14,1 (x+38&,y-8:16,0  4:4260: \192,71G:16,-16:0,-16:-16,-16:-16,16:0,16:16,16:  q=1̱w$-31 >#1;1,0;7;0;w$(qq+31) 10 :q: D7:0:l=10 20:l,1;z$(11 ):l ?x=1688X24:x,12 :0,80P:x ?y=12 92\16:16,y:72H,0:y  11 ,3;"A B C";13 ,3;"0 0 ?";15,3;"0 1 ?";17,3;"1 0 ?";19,3;"1 1 ?"  Px=16820032 :x,79O:16,0:23,-23:0,-16:-24,-24:-16,0:-23,23:0,16:24,24:x Z H6100:n=14:g$:r=07:b:g$+r,b:r:n ?"a",1,3,7,15,31,63?,127,255,"b",128,192,224,240,248,252,254,255,"c",255,254,252,248,240,224,192,128,"d",255,127,63?,31,15,7,3,1  z b` P\\TSTX-ORB00011011Wr BITS 2,3,5 & 6 satisfy (A OR B) but not (A AND B). tL $d d4 \ +-AND OR NANDNOR X-ORfmacC !! EXCELLENT LOGIC !! # GdA