Specifications

Commands - 124
VARPTR
Numeric Function
SYNTAX: VARPTR(variable)
PURPOSE: To return the address in RAM of the variable. This command is similar to VARPTR found in other
BASICs. Unlike VARPTR, the address of a string variable is returned directly.
REMARKS: variable is any CAMBASIC variable.
This function may be used to pass data other than single bytes to external machine or assembly
language routines. It is also used to find uncommitted RAM for temporary data storage.
This function returns an integer value that is the address in memory at which the value of a specified
numeric variable or numeric array resides. In the case of strings, the value returned is the address of
a vector (or address) that points to the string. This function may be used directly in the PEEK or
POKE functions and in the CALL statement for memory address references.
The format of the stored CAMBASIC variable values is as follows:
Numbers are first normalized to a standard fractional binary form, with the binary point to the right of
the sign bit of the mantissa, and stored in four bytes.
The least significant byte appears at the lowest address. The first three bytes are the mantissa, with
the sign in the most significant bit of the third byte. A sign bit of “1” designates a negative value.
The fourth byte contains the exponent, in “excess 128” notation (i.e., the value is always positive and
equals the actual binary exponent plus 128). As an example, the hexadecimal string:
LSB Mantissa MSB Exponent
MMMMMMMM MMMMMMMM S.MMMMMMM 1EEEEEEE
Mem Mem+1 Mem+2 Mem+3
The normalized binary notation yields decimal equivalents which may not be obvious. The floating
point numbers are shown with the LSB on the left. For more information see “An Introduction to
Microcomputers,” Volume 1, by Osborne/McGraw–Hill.
Scalar (simple) and numeric array variables reside above a program in RAM and are relocated upward
as new program lines are entered.
Strings are stored one character per byte, with the left–hand character first. The address returned is
the left–hand character.
Strings are stored in two ways. A literal string (e.g., A$ = "string") is stored in the program line in
which it appears. Other strings that are formed as a result of string operations (like concatenation) are
stored starting at the top of RAM and build down towards the numeric variables.