Varptr – Remote Processing CAMBASIC User Manual

Page 170

Advertising
background image

Comm ands - 137

VARPTR

Numeric Fun ction

SYNTAX:

VARPTR( variable )

PURPOSE:

To return the address in RAM of the variable. This command is similar to VARPTR found in other
BASICs. Unlike VARP TR, the address of a string variable is returned directly.

REMARK S:

variable is any CAMBASIC variable.

This functio n may be used to pass data other than single bytes to exte rnal m achine or assembly
language r outines. It can find unco mmitte d RAM for tem porar y data stora ge. Use it to tra nsfer da ta
from arr ays to Flash or extended memor y.

This function returns an integer value that is the address in memory at which the value of a specified
numeric variable or num eric array r esides. VAR PTR w ill not return the address of a string array.
This function may be used directly in the PEEK or P OKE functions and in the CALL statement for
memo ry addre ss referenc es.

The form at of the stored CA MBASIC variable values is as follows:

Number s 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 b ytes.

The least sig nificant byte ap pears at the lowest addr ess. The fir st three byte s are the m antissa, 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 exam ple, the hexadecimal string:

LSB

Man tissa MSB

Exponent

M M M M M M M M M M M M M M M M S. M M M M M M M

1EEEEEEE

M e m

Mem+ 1

Mem+ 2

M e m + 3

The norma lized binary notation yields decimal equivalents which may not be obvious. The floating
point numb ers ar e shown w ith the LSB on the left. F or m ore infor mation see “A n Introdu ction to
Micr ocomp uters, ” V olume 1, by Osbor ne/M cGra w– Hill.

Scalar (simple) and numeric array variables reside above a program in RAM and are relocated
upward as new pr ogram lines are entered.

Strings ar e stored o ne char acter pe r byte, with the left– hand char acter fir st. T he addr ess retur ned is
the left– hand character.

Advertising