The tough part of this exercise
is
that the screen display code needed to
POKE
is
different from the
PET
ASCII code that
C$
is
assigned.
As
covered in
Chapter
6,
the screen code
ois
equivalent to a 6-bit ASCII subset
with
ASCII
bit 7
moved over into screen bit
6:
l
-'-
r""-----
~_-.,
76543210
~
o= eharaeter
1
= graphie
(shifted)
L
1......-.....,
6-bit
sereen
eode
o=eharaeter
1
= graphie
(shifted)
This
is
what
line 150 in the program does
with
the logic operation:
(ASC(C$)AND128)/2
OR
(ASC(C$)AND63)
Well
go
over this operation piece by piece.
382
ASC(C$)
AND 128
/2
OR
provides the numerical equivalent of the character
C$.
As
a number, it can
be
manipulated arithmetically (and
logically).
12810=8016. This AND operation masks off
(zeroes)
ail
but the high-order bit (bit
7) of the ASCII code to isolate
it. Regardless of the previous value of
C$,
after this
operation the term
has
a value of:
100000002 or 000000002.
Divide by
2.
In
binary, division by 2
is
equivalent to a
logical right shift one bit. It admittedly requires a little
background to come up
with
this step. After this opera-
tion. the term has a value of:
010000002 or 000000002.
Thus, we have moved bit
7 of the
ASCII
code into bit 6
and replaced bit
7
with
a
zero.
This operation
will
combine the bit configuration
already developed (010000002 or 000000002)
with
the
bit configuration yet
to
be
discussed. (ASC(C$)AND63).
The
OR
operation
is
performed last
(see
Table 3-4).