Expressions

Expression precision

TASM always uses 32-bit arithmetic in Ideal mode. In MASM mode, TASM
uses either 16- or 32-bit arithmetic depending on whether you select
the 80386 processor. Therefore, some expressions might produce
different results depending on which processor you've selected. For
example,

(1000h * 1000h) / 1000h

evaluates to 1000h if you select the ≥80386 processor, or to zero if
you select the 8086, 80186, or 80286 processors.


Symbols in expressions

Standard symbol values

The following symbols always represent specific values and don't have
to be defined for you to use them:

Symbol Value
────── ─────
$ Current location counter
NOTHING 0
? 0
UNKNOWN 0
BYTE 1
WORD 2
DWORD 4
FWORD 6
PWORD 6
QWORD 8
TBYTE 10
NEAR 0ffffh
FAR 0fffeh
PROC Either 0ffffh or 0fffeh, depending on current MODEL
CODEPTR Either 2 or 4, depending on current MODEL
DATAPTR Either 2 or 4, depending on current MODEL


Simple symbol values

TASM returns the following values for symbols used by themselves:

Expression Value
────────── ─────
address_name Returns the address
numerical_expr_name Returns the value of the numerical expression
table_name | Returns the default value for the table member
table_member_name specified in the definition of the table
struc/table_member_name Returns the offset of the member within the
structure or table (MASM mode only)
record_name Returns a mask where the bits reserved to
represent bit fields in the record definition
are 1, the rest are 0
record_name <...> Returns the initial value a record instance
would have if it were declared with the same
text enclosed in angle brackets
record_name {...} Similar to record_name <...>
record_field_name Returns the number of bits the field is
displaced from the low order bit of the
record (also known as the shift value)
enum_name Returns a mask where the bits required to
represent the maximum value present in the
enum definition are 1, the rest are 0
segment_name Returns the segment value
group_name Returns the group value
struc/union_name Returns the size in bytes of the structure or
union, but only if it is 1, 2, or 4; all
other sizes return a value of 0
type_name If the type is defined as a synonym for a
structure or union, the value returned is the
same as for a structure or union. Otherwise,
the size of the type is returned (with 0ffffh
for short and near labels, and 0fffeh for far
labels)
proctype_name Returns 0ffffh if the proctype describes a
near procedure, or 0fffeh for a far procedure

All other symbols return the value zero (0).

Note that when you use a text macro name in an expression, Turbo
Assembler substitutes the string value of the text macro for the text
macro symbol. Similarly, when you use an alias name, TASM substitutes
the symbol value that the alias represents for the alias symbol.