Demonstrates the use of binary numbers and calculates them from other number systems.
Appears on
Capital Area Timex Sinclair User Groupโs Library Tape.
One of a series of library tapes. Programs on these tapes were renamed to a number series. This tape contained programs 20083 to 20120. These tapes were compiled by Tony Willing.
Gallery
Source Code
10 REM 11 REM program 101 REM SEt up 103 REM 110 GO SUB 400: LET number=0: GO SUB 300 115 REM 116 REM Menu 117 REM 120 PRINT AT 20,1;"Press "; INVERSE 1;"C"; INVERSE 0;"alculate or "; INVERSE 1;"D"; INVERSE 0;"emonstrate" 130 LET a$=INKEY$: IF a$="" THEN GO TO 130 140 IF a$="d" THEN GO SUB 500: GO TO 120 150 IF a$="c" THEN GO SUB 600: GO TO 120 160 GO TO 130 300 REM 301 REM Display binary Number 302 REM 310 LET power=128: LET remain=number 320 FOR x=0 TO 7 330 LET result=1: LET remain=remain-power 340 IF remain<0 THEN LET remain=remain+power: LET result=0 350 LET z=x*4+1: LET color=4-2*result: FOR y=3 TO 9: PRINT AT y,z; PAPER color;" ": NEXT y 360 PRINT AT 12,z;result 370 LET power=power/2: NEXT x 380 LET a$="00"+STR$ number: LET a$=a$(LEN a$-2 TO LEN a$): PRINT AT 17,22;a$ 390 BEEP .5,number/4: RETURN 400 REM 401 REM Display screen 402 REM 410 BORDER 4: PAPER 6: INK 1: CLS 420 LET power=256: FOR x=0 TO 7: LET power=power/2: LET z=x*4+1: PRINT AT 1,z; "d";7-x;AT 2,z; INK 3;power: PLOT 32*x+7,96: DRAW 0,55: PLOT 32*x+24,96: DRAW 0,55: NEXT x 430 PRINT AT 0,0;"(";AT 0,31;")": PLOT 6,174: DRAW 244,0: PRINT AT 14,10; INK 7; PAPER 1;"DATA BUS" 440 PRINT AT 13,0;"(";13,31;")": PLOT 6,64: DRAW 244,0: PRINT AT 14,10; INK 7; PAPER 1;"BINARY NUMBER" 450 PRINT AT 17,5;"Decimal Number--" 460 RETURN 500 REM 501 REM Demonstration 502 REM 510 PRINT AT 20,1;"Press "; INVERSE 1;"M"; INVERSE 0;"enu or hold down "; INVERSE 1;"F"; INVERSE 0;"reeze" 520 FOR a=1 TO 255: LET Number=a: GO SUB 300 530 IF INKEY$="m" THEN RETURN 540 IF INKEY$<>"" THEN GO TO 540 550 NEXT a: RETURN 600 REM 601 REM Calculate 602 REM 610 PRINT AT 20,1;"Enter a value from zero to 255" 620 INPUT "Decimal number? ";number 630 LET number=INT number: IF number>255 OR number<0 THEN GO TO 620 640 GO SUB 300: RETURN 9999 SAVE "BINARY NO." LINE 1