VARPTR
or
VARPTR
(variable)
VARPTR (#buffer)
Function
Returns the absolute memory address.
VARPTR can help you locate a value in memory. When used with
variable, it returns the address of the first byte of data identified with
variable.
When used with buffer, it returns the address of the file's
data
buffer.
If the
variable you specify has not been assigned a value, an "Illegal
Function Call" occurs. If you specify a
buffer that was not allocated
when loading BASIC, a "Bad file number" error occurs. (See Chapter
1 for information on how to load BASIC.)
VARPTR is used primarily to pass a value to a machine-language
subroutine via USR[digit]. Since VARPTR returns an address which
indicates where the value of a variable is stored, this address can be
passed to a machine-language subroutine as the argument
of
USR;
the subroutine can then extract the contents
of
the variable with the
help of the address that was supplied to
it.
If VARPTR returns a negative address, add it to 65536 to obtain the
actual address.
If VARPTR(integer variable) returns address
K:
Address K contains the least significant byte (LSB) of the 2-byte
integer.
Address
K + 1 contains the most significant byte (MSB) of
the
integer.
If VARPTR(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).
*(K) signifies "contents of address K"
2-174