BASIC
VARPTR (variable
name)
Returns an address-value
which
will help
you locate where the variable name
and
its value
are stored
in memory.
If the variable
you
specify has not
been assigned a
value, an
FC
error
will occur when this function is called.
If
VARPTR(
integer variable) returns address
K:
Address
K
contains the least significant
byte (LSB) of 2-byte integer.
Address
K
+
1 contains
the
most
significant
byte (MSB) of integer.
You
can display these bytes (two's complement decimal representation)
by
executing
a PRINT PEEK (K) and a PRINT PEEK (K +
1
)
.
If
\
ARPTR(single precision variable) returns address
K:
(K)*
=
LSB of value
(K +
1
)
=
Next most significant
byte (Next
MSB)
(K +
2)
=
MSB
with hidden (implied) leading one. Most significant
bit is the sign
of the number
(K +
3)
=
exponent
of value excess 128
(128
is added to the
exponent).
If \'ARP7R(double
precision variable) returns K:
(K) = LSB
of value
(K+
1)
=
Next
MSB
(K +...)=
Next MSB
(K +
6)
=
MSB with hidden
(implied)
leading
one. Most significant
bit is the sign
of the
number.
(K +
7)
=
exponent
of
value
excess 1 28
(
1
28
is
added to the exponent)
.
For single
and double precision values, the
number
is stored in normalized
exponential
form, so that
a
decimal is assumed before the MSB.
1 28 is added
to
the
exponent. Furthermore, the high bit of MSB is used
as a
sign bit.
It is set to if the
number is positive or
to 1
if
the
number is negative
. See examples below
.
You can
display
these bytes by executing the appropriate PRINT
PEEKfjc,) where x
=
the address
you
want
displayed . Remember, the result will
be
the decimal
representation
of byte, with bit 7 (MSB) used as a sign bit. The number
will be in
normalized exponential form with
the
decimal assumed
before
the MSB.
128 is
added
to
the
exponent,
If
VARP1R(string
variable) returns K:
(K)
=
length
of string
(K
+
1)
=
LSB of string value starting address
(K +
2)
=
MSB of string value
starting
address
*
(K) signifies
"contents of address K"
The
address will
probably be in high RAM where string storage space has
been
set
aside.
But,
if your string variable
is a constant (a
string
literal), then it will point
to
the
area
of
memory
where
the program line
with
the constant is stored, in the
program buffer area.
Thus, program statements like
A$
=
"HELLO"
do not use string
storage space.
193