In high-level languages, a “pointer” (or pointer variable) is an address that is stored in a variable. Assembly language also uses pointer variables, but the term “pointer” has a wider use. The indirect memory operands discussed in the previous section can be thought of as pointers stored in registers.
An address can be stored in a pointer variable for later use. Program procedures (including OS/2 systems calls) frequently pass pointer variables onto the stack to transfer data between the calling program and the called procedure.
Summary: A pointer variable must be transferred to registers before it can be used.
Regardless of the reason for maintaining it, a pointer variable to data cannot in itself be directly used in MASM statements. (Pointers to code can be used directly.) It must first be loaded into registers as an indirect memory operand.
There is a difference between a far address and a far pointer. A “far address” is the address of a variable located in a far data segment. A “far pointer” is a variable that can specify both a segment and an offset. Like any other variable, a pointer variable can be located in either the default (near) data segment or in a far segment.
Previous versions of MASM allow pointer variables but provide little support for them. In previous versions, any address loaded into a variable can be considered a pointer, as in the following statements:
Var BYTE 0 ; Variable
npVar WORD Var ; Near pointer to variable
fpVar DWORD Var ; Far pointer to variable
If a variable is initialized to the name of another variable, the initialized variable is a pointer, as shown in the example above. However, in previous versions of MASM, the CodeView debugger recognizes npVar and fpVar as word and doubleword variables. CodeView does not treat them as pointers, nor does it recognize the type of data they point to (bytes, in the example).
The new directive TYPEDEF and the new capabilities of ASSUME make it easier to manage pointers in registers and variables. These directives are discussed in the next two sections. Basic pointer and address operations are covered in Section 3.3.3.