EasyManua.ls Logo

Commodore VIC-20 - Page 85

Commodore VIC-20
308 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Logical
operators
work
by
converting
their
operands
to
sixteen-bit,
signed,
two's-complement
integers
in
the
range
-32768
to
-i-
32767.
(If
the
operands
are not
in
this
range,
an
error
results.)
If
both
operands
are
supplied
as 0
or
-1,
logical
operators
return
0
or
-1.
The
given
operation
is
performed
on
these
integers
in
bitwise
fashion,
i.e.,
each
bit
of
the
result
is
determined
by
the
corresponding
bits
in
the
two
operands.
Thus,
it
is
possible
to
use
logical
operators
to
test
bytes
for
a
particular
bit
pattern.
For
example,
the
AND
operator
may
be
used
to
"mask"
all
but
one
of
the
bits
of
a
status
byte
at
a
machine
I/O
port.
The
OR
operator
may
be
used
to
"merge"
two
bytes
to
create
a
particular
binary value.
The
following
examples
will
demonstrate
how
the
logical
operators
work:
63
AND
16
-
16
63
-
binary
111111
and
16
=
binary
10000,
so 63
AND
16=16
15
AND
14
=14
15
-
binary
1111
and
14
=
binary
1110,
so
15
AND
14
=
14
(binary
1110)
-1
AND
8
=
8
-1 =
binary
11111111
and
8
=
binary
1000,
so
-1
AND
8
=
8
4
OR
2
=
6
4
=
binary
100 and
2
=
binary
10,
so
4
or
2
=
6
(binary
110)
10
OR
10
=10
10
=
binary
1010,
so
1010
OR
1010
-
1010
(10)
-1
OR
-2
=
-1
-1
m
binary
11111111
and
-2
=
binary
11111110,
so
-
1
OR
-
2
=
-1.
The
bit
complement
of
sixteen
zeros
is
sixteen
ones,
which
is
the
two's
complement
representation
of
-1.
NOT
X=
{-X)
+
1
The
two's
complement
of
any
integer
is
the
bit
complement
plus
one.
STRING
OPERATIONS
Strings
may
be
concatenated
using
+
.
For
example:
10
A$
=
"FILE"
:
B$
=
"NAME"
20
PRINT
AS -
BS
30
PRINT
"NEW1
+ AS -
BS
RUN
FILENAME
NEW
FILENAME
69

Other manuals for Commodore VIC-20

Related product manuals