IDEAL vs. MASM mode
No formal standard exists for the assembly language. For better or
worse, the syntax used by Microsoft's assembler (MASM) is followed by
convention. In addition to supporting MASM syntax, Borland has
introduced the Ideal mode, a MASM derivative, with a clearer and more
consistent syntax.
Ideal mode features include:
■ duplicate member names among multiple structures
■ complex HIGH and LOW expressions
■ predictable EQU processing
■ correct handling of grouped data segments
■ improved consistency among directives
■ sensible bracketed expressions
■ 30% faster assembly than MASM mode
Entering and leaving Ideal mode
Use the IDEAL and MASM directives to switch between Ideal and MASM modes.
Turbo Assembler always starts assembling a source file in MASM mode.
To switch to Ideal mode, include the IDEAL directive in your source
file before using any Ideal mode capabilities. You can switch back and
forth between MASM and Ideal modes in a source file as many times as
you wish and at any place.
Differences between Ideal and MASM mode
Ideal mode uses nearly all MASM's keywords, operators, and statement
constructions. In Ideal mode, however, directive keywords such as
SEGMENT, PROC, LABEL, and STRUC appear before the identifying symbol
name.
Square brackets
The biggest difference between Ideal and MASM mode expressions is the
way square brackets function. In Ideal mode, square brackets always
refer to the contents of the enclosed quantity (i.e. a memory
reference). Brackets never cause implied additions to occur. Many
standard MASM constructions, therefore, are not permitted in Ideal
mode.
In Ideal mode, square brackets must be used in order to get the
contents of an item. For example,
mov ax,wordptr
displays a warning message. You're trying to load a pointer (wordptr)
into the AX register. The correct form is
mov ax,[wordptr]
Using Ideal mode, it's clear you are loading the contents of the
location addressed by wordptr (in the current data segment at DS) into
AX.
If you wish to refer to the offset of a symbol within a segment, you
must explicitly use the OFFSET operator, as in this example:
mov ax,OFFSET wordptr
Operators
The changes made to the expression operators in Ideal mode increase
the power and flexibility of some operators while leaving unchanged
the overall behavior of expressions. The precedence levels of some
operators have been changed to facilitate some common operator
combinations.
The period (.) structure member operator is far more strict in Ideal
mode when accurately specifying the structure members you're referring
to. The expression to the left of a period must be a structure
pointer. The expression to the right must be a member name in that
structure.
Segments and groups
In Ideal mode, any data item in a segment that is part of a group is
considered to be principally a member of the group, not of the
segment. An explicit segment override must be used for Turbo Assembler
to recognize the data item as a member of the segment.
MASM (and therefore Turbo Assembler's MASM mode) handles this
differently; a symbol is treated as part of a segment when the symbol
is used with the OFFSET operator, but as part of a group when the
symbol is used as a pointer in a data allocation. This can be
confusing because when you directly access the data without OFFSET,
MASM incorrectly generates the reference relative to the segment
instead of the group.