Service manual
50
D
e
cim
a
l to Bin
a
ry
The following simple computer program in BASIC will convert any decimal number less
than 4096 into Binary.
10 DIM
W(12)
200 Z=Z MOD 16
20 INPUT"DECIMAL ? "N 210 E=Z DIV 8
30 IF N>4095 THEN GOTO 20 220 Z=Z MOD 8
40 IF N<0 THEN GOTO 2
0
230 F=Z DIV 4
50 J=N DIV 2048 240 Z=Z MOD 4
60 Z=N MOD 2048 250 G=Z DIV 2
70 K=Z DIV 1024 260 Z=Z MOD 2
80 Z=Z MOD 1024 270 H=Z
90 L=Z DIV 512
280
W(0)=J
100 Z=Z MODl512
290
W(1)=K
110 M=Z DIV\256
300
W(2)=L
120 Z=Z MOD 256
310
W(3)=M
130 A=Z DI
V 128 320
W(4)=A
140 Z=Z MOD 128
330
W(5)=B
150 B=Z DIV 64
340
W(6)=C
160 Z=Z MOD 64
350
W(7)=D
170 C=Z DIV 32
360
W(8)=E
180 Z=Z MOD 32
370
W(9)=F
190 D=Z DIV 16
380
W(10)=G
390 W(ll)=H
400PRINTW(0);W(1);W(2);W(3);
W(4);W(5);W(6);W(7);W(8);
W(9);W(10);W(
ll)
410 GOTO 20
Note: Some dialects of BASIC do not provide the MOD and DIV operators used in the
above program. The alternative method available in less comprehensive dialects is far from
elegant, but works just the same.
For A=B MOD C ...
use
... A=((B/C)-(INT(B/C)))*C
For A=B DIV C ...
use
... A=INT(B/C)
The pin-out sketches, on the following pages, indicate the connections necessary for
normal read operation, NOT for programming. Every care has been taken to ensure that the
information is accurate, but no responsibility can be accepted for problems arising from
errors or omissions in this book. It is recommended that you consult the appropriate
literature from the supplier of each particular device.