EasyManua.ls Logo

Commodore Plus 4 - Page 329

Commodore Plus 4
464 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...
Interfacing
with.
BASIC
317
the
exponent)
to
zero.
The
nonzero
absolute
value
of
the
floating
point
accumula
tor
can
be
calculated
using
the
following
formula:
[2~8*($62)
+
2~16*($63)
+
2"24*($64)
+
2~32*($65)]
*
2[($61)"128]
where
($62)
means
the
contents
of
memory
location
$62.
Example:
In
this
example,
the
USR
function
is
defined
as
a
routine
that
returns
the
current
contents
of
the
specified
register
of
the
graphics
chip.
BASIC
program
is
as
follows:
10
P0KE1281,0:P0KE1282,32
20
PRIFT'WHICH
REGISTER
IS
DESIRED";:I]mjT]Sr%
30
M=USR(lT%):IPM<OTHE]SrPRI]SrT//ILLEGAL
REGISTER
1TUMBER//:GOTO2O
40
Line-by-Line
Explanation
10
These
two
POKEs
change
the
USR
vector
to
point
to
the
new
routine.
20
The
user
is
asked
for
an
integer
register
number.
30
The
USR
function
performs
error
checking,
returning
a
negative
value
if
an
illegal
register
number
was
requested.
An
illegal
request
causes
control
to
return
to
line
20.
40
The
contents
of
the
register
are
displayed.
The
machine
code
subroutine
to
process
the
USR
function
can
be
entered
with
the
machine-language
monitor. This
subroutine
converts
the
register
number
in
the
floating
point
accumulator
to
a
1-byte
index,
checks
it
for
validity,
and
gets
the
appropriate
contents
of
the
graphics
chip
register.
The
subroutine
then
converts
this
value
into
a
floating
point
number
and
places
it
in
the
floating
point
accumulator
for
return.
A
negative
number
is
returned
to
indicate
an
error.
Look
at
sign
of
input
register
number.
If
negative,
it
is
invalid,
so
return.
Look
at
the
exponent
of
input
register
number.
If
zero,
it
is
zero,
so
skip
conversion.
Prepare
to
subtract.
Load
accumulator
with
136.
Subtract
the exponent.
This
is
the
number
of
times
to
divide
by
2.
Get
the
mantissa.
Decrement
number
of
times
to
divide.
If
negative,
then
done,
so
go
on.
Divide
by
2.
2000
2002
2004
2006
2008
2009
200B
200D
200E
2010
2011
2013
A5
30
A5
F0
38
A9
E5
A8
A5
88
30
4A
66
3A
61
0E
88
61
62
03
LDA
BMI
LDA
BEQ
SEC
LDA
SBC
TAY
LDA
DEY
BMI
LSR
$66
$203E
$61
$2016
#$88
$61
$62
$2016