EasyManua.ls Logo

Commodore VIC-20 - Page 153

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...
the
previous
instruction(s),
but
by
internally
examining
the status
register.
As
was
just
mentioned,
there
is
a
"zero
result"
flag
in
the status
register.
The
"BEQ"
instruction
branches
if
the
"zero
result"
flag
(known
as
"Z")
is
set.
Every
branch
instruction
has
an
opposite
branch
instruction.
The
BEQ
instruction
has
an
opposite
instruction
"BNE"
("branch
on
result
NOT
equal
to
zero,"
i.e.,
"Z"
not
set).
The
index
registers
have
a
number
of
associated
instructions
which
modify
their
contents.
For
example,
the
"IMX"
instruction
will
"increment
the
X
index
register."
If
the
X
register
contained
$FF
before
it
was
incremented
(the
maximum
number
the
X
register
can
contain),
it
will
"wrap
around"
back
to
zero.
If
we
wanted
a
program
to
continue
to
do
something
until
we
had
performed
the
increment
of
the
X
index
that
pushed
it
around
to
zero,
we
could
use
the
BNE
instruction
to
continue
"looping"
around,
until
X
became
zero.
Apart
from
INX,
there
is
"DEX",
which
will
decrement
the
X
index
register.
If
it
is
zero,
it
will
wrap
around
to
SFF.
Similarly,
there
are
"INY"
and
"DEY"
for
the
Y
index
register.
But
what
if
a
program
didn't
want
to
wait
until
X
or
Y
had
reached
(or
not
reached)
zero?
Well
there
are
comparison
instructions,
"CPX"
and
"CPY",
which
allow
the
machine
language
programmer
to
test
the
index
registers
with
specified
values,
or
even
the
contents
of
memory
locations.
If
we
wanted
to
see
if
the
X
register
contained
$40,
we
would
use
the
instruction:
CPX
#$40
compare
X
with
the
"value"
$40.
BEQ
(some
other
branch
to
somewhere
else
in
the
program,
if
part
of
the
this
condition
is
"true."
program)
The
compare
and
branch
instructions
play
a major
part
in
any
machine
language
program.
The
operand
specified
in
a
branch
instruction
when
using
VICMon
is
the
address
of
the
part
of
the
program
the
branch
should
go
to,
if
taken.
However,
the
operand
is
only,
in
fact,
an
"offset"
from
where
the
program
currently
is.
to
the
address
specified.
This
offset
is
just
one
byte,
and
therefore
the
range
that
a
branch
instruction
can
branch
to
is
limited
from
128
bytes
backward,
to
127
bytes
forward;
this
is
a
total
range
of
255
bytes,
which
is,
of
course,
the
maximum
range
of
values
one
byte
can
contain.
VICMon
will
tell
you
if
you
branch
out
of
range,
by
refusing
to
"assemble"
that
instruction.
It
is
unlikely
that
you
will
be
doing
such
huge
branches
for
quite
a
while
anyway.
For
nearly
all
situations
this
is
adequate
anyway.
The
branch
is
a
"quick"
instruction
by
machine
language
standards
because
of
this
"offset"
principle
as
opposed
to
an
137

Other manuals for Commodore VIC-20

Related product manuals