Assembly Language Help (alang.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Specify Type for Expression
◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
Syntax: qualifiedtype PTR expression
PTR qualifiedtype
See also: TYPE, THIS, qualified type
Description:
The first syntax treats <expression> as having the specified type.
Type casting can be used with forward references or unlabeled
addresses to specify a reference size, type, or distance.
The second syntax is used in defining qualified types.
See: ◄qualified type►
The PTR keyword can also appear in qualified types to indicate
that the type is a pointer variable.
The <qualifiedtype> can be any qualified type. The <expression>
can be any valid expression. If <qualifiedtype> is a distance,
<expression> cannot be a memory expresssion or a data label.
See: ◄qualified type►
You can use a constant as the left operand to PTR in compatibility mode.
Otherwise, you must use a type expression. With OPTION M510, a constant
must have a value of 1 (BYTE), 2 (WORD), 4 (DWORD), 6 (FWORD),
8 (QWORD) or 10 (TBYTE). The assembler treats the constant as the
parenthesized type. Note that the TYPE operator yields a type expression,
but the SIZE operator yields a constant.
; With OPTION M510
MyData DW 0
mov WORD PTR [bx], 10 ; Legal
mov (TYPE MyData) PTR [bx], 10 ; Legal
mov (SIZE MyData) PTR [bx], 10 ; Legal
mov 2 ptr [bx], 10 ; Legal
; Without OPTION M510
MyData WORD 0
mov WORD PTR [bx], 10 ; Legal
mov (TYPE MyData) PTR [bx], 10 ; Legal
; mov (SIZE MyData) PTR [bx], 10 ; Illegal
; mov 2 PTR [bx], 10 ; Illegal
Example:
mov ax, (MyStruct PTR [bx]).Username
fld TBYTE PTR MaxConvolution
INVOKE MyRoutine, PTR TempValue
Under MASM 5.1, applying the PTR operator to a data initializer de-
termines the size of the data displayed by CodeView. You can still use
PTR in this manner in MASM 6.1, but it does not affect CodeView typing.
Defining pointers with the TYPEDEF directive allows CodeView to generate
correct information.
-♦-